Hi Pieter,
As far as I know, FME currently doesn't support simple calculating function for date / datetime values. You will have to append the functionality with creating a custom transformer or defining a python script. Or, you can also consider to use
the DateDifferenceCalculator custom transformer from FME Store.
http://fmestore.safe.com/transformers/DateDifferenceCalculator.htm
Takashi
Currently the store transformer is the way to go to do calculations on dates.
Hi,
here is a solution pased on a PythonCaller:
-----
import fmeobjects from datetime import date from time import strptime def FeatureProcessor(feature): # Get attributes my_date = feature.getAttribute("my_date") my_timestamp = feature.getAttribute("my_timestamp") # Parse string attributes to time objects t1 = strptime(my_date, "%Y%m%d%H%M%S") t2 = strptime(my_timestamp, "%Y%m%d%H%M%S.000000") # Convert to date objects d1 = date(t1.tm_year, t1.tm_mon, t1.tm_mday) d2 = date(t2.tm_year, t2.tm_mon, t2.tm_mday) # Number of days between the two dates day_delta = abs((d1 - d2).days) # Set result attribute "delta" feature.setAttribute("delta", day_delta) -----
It requires two attributes "my_date" and "my_timestamp" and will return a new attribute "delta" which will correspond to the number of days between the two input dates.
David
Hi,
Thanks for your reply and support, it works now !
I first upgraded from FME2012 to FME2013
There i used de dateconverter to convert de date-field to timestamp-format %Y%m%d%H%M%S.000000'
With de DateDifferenceCalculator i managed to calculate the difference in days.
Pieter