Skip to main content
Solved

Query A Date Field To Only Return <=90 Days From Current Date

  • April 18, 2017
  • 5 replies
  • 119 views

ngstoke
Contributor
Forum|alt.badge.img+1

I'm trying to develop a workbench that will only return records from Excel spreadsheets that are within 90 days from the current date when I run the workbench. I'd like to not have to enter the current date every time I run the workbench. Is there an expression I can use or a transformer to perform this.

Any help is greatly appreciated.

My dates are formatted as seen below.

20170525

20170624

20170708

20170902

Best answer by ciarab

dates.fmwt

Hi @ngstoke

you should be able to do this using relative dates and testing your dataset using a tester to extract your data that is within 90days of your request. I have attached a sample workflow that you can review

dates.fmwt

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

5 replies

ciarab
Contributor
Forum|alt.badge.img+9
  • Contributor
  • Best Answer
  • April 18, 2017

dates.fmwt

Hi @ngstoke

you should be able to do this using relative dates and testing your dataset using a tester to extract your data that is within 90days of your request. I have attached a sample workflow that you can review

dates.fmwt


erik_jan
Contributor
Forum|alt.badge.img+23
  • Contributor
  • April 18, 2017

Use the TimeStamper transformer to get the current date and feed that to the FeatureReader to read the data based on that date. You need to trigger the TimeStamper with a Creator transformer.


ngstoke
Contributor
Forum|alt.badge.img+1
  • Author
  • Contributor
  • April 18, 2017

dates.fmwt

Hi @ngstoke

you should be able to do this using relative dates and testing your dataset using a tester to extract your data that is within 90days of your request. I have attached a sample workflow that you can review

dates.fmwt

Thank you @ciarab I was able to modify your workflow and get the answers I was after.

 

Much appreciated

 


Forum|alt.badge.img

Hi @ngstoke

are you using FME 2017? With FME 2017 new datetime functionality, your workflow can be as simple as this:

If you are working with FME 2017.0 you will only have old TimeStamper - which will still do the job for you. In FME 2017.1 we have added new DateTimeStamper which is more powerful and user friendly. You can download FME 2017.1 beta from https://www.safe.com/support/support-resources/fme-downloads/beta/


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • April 19, 2017

@ngstoke

You can of course do it in a single transformer, just bit of tcl datecalcing needed...

In a tester test for

@abs(

[clock format [clock scan today] -format {%j}] - [clock format [clock scan {YourAttribute}] -format {%j}]

)<=90

Format you posted is basic format for cloc scan.

-format %j is days counting in 3 digits (which you could also use as input if needed )