Question

From and To date Selection...Possible?

  • 22 December 2014
  • 3 replies
  • 8 views

Badge

This question is related to the last question I asked regarding the date and time seperation issue-

 

https://safecommunity.force.com/CommunityAnswers?id=906a0000000d6Yi

 

 

Now, I have a column Date in my table which is having different dates, and the number of datasets in large amount. I just want, if the user runs the WB from 'Prompt and Run Translation', he can select valid dates from the respective  input colum.

 

Suppose there are dates from 1/1/2014 to 1/2/2014 (DMY), he should be able to selelct from and to dates according to his needs and the output should show only those section of dates and other related columns also. 

 

Please feel free to ask questions if i am unable to explain !!!

3 replies

Userlevel 2
Badge +17
Hi again :)

 

 

D/M/Y date strings cannot be compared their large/small directly, but you can use the DateFormatter to convert D/M/Y to YYYYmmdd, and then compare the YYYYmmdd strings with < > <= >= operators.

 

Example for DateFromatter parameter settings:

 

Source Date Format: %d/%m/%Y

 

Destination Date Format: FME Date (%Y%m%d)

 

 

In the data flow, the ParameterFetcher or the AttributeCreator can be used to get the user parameters and add the values to each feature as their attributes.

 

After changing format of the date strings with the DateFormatter, you can filter the features based on the date value (YYYYmmdd format) with the Tester.

 

 

Takashi
Badge
Hi Takashi. Thank you so much for the reply.

 

The DateFormatter worked exactly what I wanted. But I was not able to get the correct output from Prompt Run Translation.

 

What I tried is-

 

- Renamed the Date column to 'Start Date' & 'End Date' and copied the attributes from 'Date' column to 'Start Date' and 'End Date' column.

 

- Now both the columns have same value.

 

- Made a Tester transformer with 'Begins With' and 'Ends With' clause.

 

- This is where the user needs to change the dates.

 

This is a temporary thing, but the output is not as I require. 

 

More suggestions are welcoomed.
Userlevel 2
Badge +17
I don't think "Begins With" and "Ends With" operators are suitable to your case.

 

If all the attributes store date strings in YYYYmmdd format, you can determine if the Date is between Start and End with this test clause.

 

 

Start Date <= Date

 

AND

 

Date <= End Date

 

 

The <= or < operator can be used to compare YYYYmmdd date strings appropriately.

 

Don't forget to set the "Pass Criteria" parameter to "All Tests (AND)".

 

Begins/Ends With operator should be used to determine if a character string begins/ends with a specified string. 

 

Reply