Skip to main content
Solved

Next Date Calculation

  • April 15, 2016
  • 5 replies
  • 36 views

Hi All,

I am trying to calculate the next date from a starting date - for example Waste collection. I have a starting date in 2015 and would like to calculate the next pick up.

Pickup is every 7 days. In Excel you can using the CEILING function to round up to the next multiple of 7.

Is there any way that this function could be implemented in FME?

Thanks, Matt

Best answer by lenaatsafe

Hi @gisballarat

you might also want to try DateCalculator custom transformer.

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

fmelizard
Safer
Forum|alt.badge.img+21
  • Safer
  • April 17, 2016

We're going to be attacking Dates and providing date arithmetic in FME 2017, but until then, I suspect Python is the way to go.

I managed to get this code to work in the PythonCaller (workspace attached). Ahead of time you'd need to get the attributes you want to work on set up -- I've hard coded the sample.

 

def input(self,feature):

yyyymmddStringFromFME = str(feature.getAttribute('date1'))

pythonDateTime = datetime.strptime(yyyymmddStringFromFME, "%Y%m%d%H%M%S")

oneWeek = timedelta(7)

oneWeekLater = pythonDateTime + oneWeek

yyyymmddStringForFME = oneWeekLater.strftime("%Y%m%d%H%M%S")

feature.setAttribute('date2',yyyymmddStringForFME)

self.pyoutput(feature)

Sample workspace attached. addoneweek.fmw


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • April 18, 2016

I usually use tcl "clock scan", "clock format" and "expr" to do such calculations mostly in transformers with a expressionevaluation capability. (attributecreator, testers etc.).


Forum|alt.badge.img
  • Best Answer
  • April 18, 2016

Hi @gisballarat

you might also want to try DateCalculator custom transformer.


  • April 19, 2016

Hi @gisballarat ,

You can use DateCalculator custom transformer. You need to provide the MM/DD/YYYY format as input.


geospatiallover
Participant
Forum|alt.badge.img+6

@gisballarat, it was nice to know about this transformer and I like its UI however I tried but for some reason my translation comes out DC_Fail = N. So I just skipped it. I used @daleatsafe instead and it worked for me. I needed to subtract one week so I just changed the + symbol to a minus sign in his code. I'll be looking forward to the DateCalculator in 2017.