Skip to main content
Hi everyone, I'm trying to select records that match todays date - could someone help me out with the best transformer to use?  I'm thinking Tester, but just not sure how to set the 'right value'?

 

I'm reading a table that contains coords for our snow plow equipment, and I'd like to only pass through those records whose date equals the current date (todays date).  Seems simple enough, just don't know the format to use.

 

www.banffmaps.ca/banffsnow

 

 

Thanks for any help

 

Steve

 

First make sure that all dates are formatted in a common way. The DateFormatter and perhaps even the custom Transformer the DateConverter will help you here. Ensuring a common syntax is often the biggest challenge. Once done, you're right perhaps the simplest approach would be the Tester, you could even supply todays date as a Published Parameter so you can key it  in using 'Prompt and Run' to select the correct features by date. Assuming you key the date in using the same format, you should be fine.

 

 

No doubt a better man/woman than I could break out something like a PythonCaller and invoke something like a CurDate() function to be much more efficient and grab the system date of your PC but I shall have to defer to those wiser than I for that...

 

 

Enjoy the snow, I'm jealous!
Morning Dave,

 

Thanks very much for the reply. 

 

I guess that's really what I'm after - a way to use the Current Date system variable.  I have my current FMW running every 10 mins to update the plow locations, but I'd really like to automatically just show locations for todays date....as it is now, it'll allow plow location information from yesterday through the process, but what I'd really like to show is plow details only for the current day/date...

 

Any other suggestions on how to 'call' the current date within Tester?

 

Thanks,

 

Steve

 


After too much time playing with Python to try to call a function to get the current date and the SystemCaller to get the current %DATE% I realised that of course FME has a TimeStamper!

 

 

So its super-simple, Creator (making sure Create At End = No, so it creates 1 feature straight away), followed by a TimeStamper with the appropriate date format to match your data, like "2013-01-09" and then put that into an attribute like _date and then test your data against it... Phew, I was so making things too hard!

Ha! That's perfect - that'll work nicely.

 

Thanks again Dave.

Steve


Here's one thing I find useful when comparing time in FME.

 

 

I convert all time to epoch time (seconds since the epoch) by using only %s to format the date.  This gives you a single numeric value for your time.
You can also use an AttributeCreator followed by the DateFormatter

 

 

Create an attribute with a value of "today" and put it through the DateFormatter and you get today's date.

 

 

It doesn't do anything more than the timestamper but it's very versatile. If you create an attribute with a value of "yesterday" you get yesterday's date. "1 week ago" and you get a date 1 week ago, "1 week" and you get the date one week in the future.

 

 


Hi all,

 

 

Just following on from EGomm's post. I've got a workspace that does that - I need to find the latest updates in a MapInfo table to do subsequent manipulations. I used '3 months ago' in an AttributeSetter, then have a Tester looking for any feature >= that date and it used to work a treat.

 

 

Using this in FME Desktop 2013, it does nothing. I've tried using AttributeCreator (now the replacement for AttributeSetter) and also copying the old AttributeSetter transformer into the other workspace, and still no good. I think this ability has been removed now. Can anyone confirm this? Or suggest an alternative?

 

 

Regards,

 

 

Ian


Good morning FME world

 

 

Thanks all, I now know how to create today's date and last week's.

 

 

The rest of the day is going to go in a blur of calculations :)

 


I'm trying to output the date 4 years and 6 months ago. Does anyone know how to do this? I can get 4 years ago and six months ago using EGomm's method, 4 years and 6 months ago, 54 moths ago and 4.5 years ago doesnt work. 

 

 

Any ideas?

Reply