Skip to main content

Hi there,

 

I am trying to filter (using tester) the data on the basis of dates (i.e. month and Year). I have converted the dates into desired format using DateTimeFormat function. When I run the tester, it does not give the right result. In the passed data tab I could see the dates row that should have been in the failed data tab. I have attached the screen shot of my test parameter. Could anyone guide where am I making the mistake?

If you can't see the logic of the tester here is the value

@DateTimeFormat(@DateTimeParse(@Value(INCIDENT_TIME), %Y-%m-%d),%m %Y) >= @DateTimeFormat(@DateTimeAdd(@DateTimeNow(),-P8M),%m %Y)

AND @DateTimeFormat(@DateTimeParse(@Value(INCIDENT_TIME), %Y-%m-%d),%m %Y) <= @DateTimeFormat(@DateTimeAdd(@DateTimeNow(),P3M),%m %Y)

 


Hi @muhammad_yasir, If you convert the datetime format into Standard FME Date/Time Format, you can compare the datetime values by setting the Comparison Mode parameter in the Tester to "Date/Time".


Hi @muhammad_yasir, If you convert the datetime format into Standard FME Date/Time Format, you can compare the datetime values by setting the Comparison Mode parameter in the Tester to "Date/Time".

@takashi I just tried that. But ended with the same result.


Hi @muhammad_yasir, If you convert the datetime format into Standard FME Date/Time Format, you can compare the datetime values by setting the Comparison Mode parameter in the Tester to "Date/Time".

Hi @takashi, I just noticed that I am getting following warning message when I run the tester.

Tester (TestFactory): TestFactory: Unable to do a date/time comparison of 'yyyymm' and 'yyyymm'. Comparing as strings instead.


Hi @muhammad_yasir, If you convert the datetime format into Standard FME Date/Time Format, you can compare the datetime values by setting the Comparison Mode parameter in the Tester to "Date/Time".

My intention was to set these expressions. Both @DateTimeParse function and @DateTimeAdd function return a datetime value formatted in Standard FME Date/Time Format.

Doesn't this work for you?

@DateTimeParse(@Value(INCIDENT_TIME), %Y-%m-%d) >= @DateTimeAdd(@DateTimeNow(),-P8M)
AND
@DateTimeParse(@Value(INCIDENT_TIME), %Y-%m-%d) <= @DateTimeAdd(@DateTimeNow(),P3M) 

Comparison Mode: Date/Time


Hi @muhammad_yasir, If you convert the datetime format into Standard FME Date/Time Format, you can compare the datetime values by setting the Comparison Mode parameter in the Tester to "Date/Time".

If you need to compare only year and month part, this expression would be available.

@DateTimeFormat(@DateTimeParse(@Value(INCIDENT_TIME), %Y-%m-%d),%Y%m) >= @DateTimeFormat(@DateTimeAdd(@DateTimeNow(),-P8M),%Y%m)
AND
@DateTimeFormat(@DateTimeParse(@Value(INCIDENT_TIME), %Y-%m-%d),%Y%m) <= @DateTimeFormat(@DateTimeAdd(@DateTimeNow(),P3M),%Y%m)

Hi @muhammad_yasir, If you convert the datetime format into Standard FME Date/Time Format, you can compare the datetime values by setting the Comparison Mode parameter in the Tester to "Date/Time".

Awesome. It worked. Thanks for clarification. Last thing, Can I add multiple but different conditions in single tester? If yes, Can you explain how?


Hi @muhammad_yasir, If you convert the datetime format into Standard FME Date/Time Format, you can compare the datetime values by setting the Comparison Mode parameter in the Tester to "Date/Time".

Consider using TestFilter instead.


Consider using TestFilter instead.

Is it the same as Tester ?


If you need to compare only year and month part, this expression would be available.

@DateTimeFormat(@DateTimeParse(@Value(INCIDENT_TIME), %Y-%m-%d),%Y%m) >= @DateTimeFormat(@DateTimeAdd(@DateTimeNow(),-P8M),%Y%m)
AND
@DateTimeFormat(@DateTimeParse(@Value(INCIDENT_TIME), %Y-%m-%d),%Y%m) <= @DateTimeFormat(@DateTimeAdd(@DateTimeNow(),P3M),%Y%m)

This condition does not work. However, above mentioned condition does work


Consider using TestFilter instead.

Similar to the Tester, but you can add any number of output ports for the number of your desired conditions. See the help on the TestFilter transformer to learn more.


Reply