Skip to main content
Question

I need to filter out CSV date by closed and within a specific time frame. I am able to find all closed items but when filtering out by DateTime Calculator, its getting rejected.


jamesb16
Contributor
Forum|alt.badge.img+1

I am doing the completion date subtracted by number amount(200 days) using Subtract Interval or Interval between dates using the completion date - DateTimeNow. the FME rejection code is INVALID_INPUT. Any suggestions is greatly appreciated

12 replies

geomancer
Evangelist
Forum|alt.badge.img+46
  • Evangelist
  • June 9, 2023

Probably the completion date from the CSV is not recognised as a date. Did you use a DateTimeConverter?


jamesb16
Contributor
Forum|alt.badge.img+1
  • Author
  • Contributor
  • June 9, 2023

Yes I am. That seems to be the place where it is be rejected out at the DateTimeCalculator which is before the DateTimeConverter.


geomancer
Evangelist
Forum|alt.badge.img+46
  • Evangelist
  • June 12, 2023

Hi, can you provide some samples of the dates (text from the CSV) you are trying to process?

And can you share the settings of the DateTimeConverter? (unfortunately I can't open your workspace, as I'm using an older version of FME)


jamesb16
Contributor
Forum|alt.badge.img+1
  • Author
  • Contributor
  • June 12, 2023

Hi,

I checked the CSV and the column is date format not text.

I created a ATTRIBUTECREATOR called < Closed 45 days> which is the date field in the CSV file I included. DATETIMECONVERTER is reading the <Closed 45 days> and results_datetime which should be the results from the DATETIMECALCULATOR which takes <CLOSED 45 days> and substracts a number value to get the results_datetime results, At least thats my understanding. I have also increased the duration in DATETIMECALCULATOR to 300 days which should have resulted in a large sampling of the data. Thanks for any assistance.csvdatetimecalc


geomancer
Evangelist
Forum|alt.badge.img+46
  • Evangelist
  • June 12, 2023

Thanks for the update.

The DateTimeConverter should convert from the input format to the FME format, so something like this:

DateTimeConverter_2CSV never contains dates, as CSV is plain text (just open it with Notepad). However lots of programs (such as Excel) will interpret the text as a date when possible.


geomancer
Evangelist
Forum|alt.badge.img+46
  • Evangelist
  • June 12, 2023

If this does not work, please open the CSV in a text editor (like Notepad) and look at the exact way the date is formatted. Your screendump was from Excel of something akin, which does not show the exact contents of the CSV but its own interpretation.


jamesb16
Contributor
Forum|alt.badge.img+1
  • Author
  • Contributor
  • June 12, 2023

I looked into Wordpad, it does show the date format like this (example 1/1/2023).

Because if the format was 20230101(ISO FORMAT), then FME would be able to convert. But since it is already formatted to the date format, is this reasoning for the inability to calculate. The original data was compiled from someone else,would it be beneficial to have it recompiled.


geomancer
Evangelist
Forum|alt.badge.img+46
  • Evangelist
  • June 12, 2023

FME needs dates to be in its own datetime-format to be able to perform calculations like with the DateTimeCalculator. So you can use the DateTimeConverter to convert dates from any format (like 1/1/2023) to FME-datetime-format.

If the dates are like 1/30/2023, set the Input Format to %N/%e/%Y

%N : One- or Two-digit month, with range 1 to 12
%e : One- or Two-digit day of month, with range 1 to the last day of the month
%Y : Four-digit year, with range 0001 to 9999
/ : Regular character, used as separator

See the complete format here.


jamesb16
Contributor
Forum|alt.badge.img+1
  • Author
  • Contributor
  • June 12, 2023

This was the format that I set the output format to: %N/%e/%Y. I have the input format to auto detect both ISO/FME formats.


geomancer
Evangelist
Forum|alt.badge.img+46
  • Evangelist
  • June 12, 2023

Edit: I corrected the image, by replacing %M in both DateTimeConverters to %N, as noted below by @jamesb16​ .

Before you can use the DateTimeCalculator, you have to make sure the date is recognised by FME. You can use the DateTimeConverter for this. Afterwards you want to export the data to CSV, so you have to convert the date once more, with a second DateTimeConverter.

DateTimeConverter_2AOf course there will be other transformers in your workspace, as you want to do some testing as well.


jamesb16
Contributor
Forum|alt.badge.img+1
  • Author
  • Contributor
  • June 12, 2023

I will check into that, for all the other transformer. Mine looks like yours,except output is %N%e%Y


geomancer
Evangelist
Forum|alt.badge.img+46
  • Evangelist
  • June 12, 2023

You are right, it should be %N instead of %M, my mistake (%M stands for two-digit minutes).

I corrected the image in my previous post.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings