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
I usually use tcl "clock scan", "clock format" and "expr" to do such calculations mostly in transformers with a expressionevaluation capability. (attributecreator, testers etc.).
Hi @gisballarat
you might also want to try DateCalculator custom transformer.
Hi @gisballarat ,
You can use DateCalculator custom transformer. You need to provide the MM/DD/YYYY format as input.
@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.