Skip to main content
Solved

Dynamic calculation of year

  • December 20, 2019
  • 1 reply
  • 412 views

Hi there,

 

I am a newbie in FME. So please accept my apology if my question sounds stupid. I want to calculate the year of the particulars date on FME.

For example, I want to calculate the year of 31st March of the current year and next year. Similarly, I want to calculate the year of 1st April for the current year, and the previous year. These calculate years along with dates would be stored in columns.

 

Looking forward for your guidance.

Best answer by bwn

Have a look at the Date/Time functions help here:

https://docs.safe.com/fme/html/FME_Desktop_Documentation/FME_ReadersWriters/!Transformer_Parameters/Date-Time-Functions.htm

The particular functions to consider are:

  • DateTimeNow() to generate the current datetimestamp, which has in it the current year
  • DateTimeFormat() to extract the current Year with format %Y as the formatter
  • DateTimeParse() to create a datetimestamp for a particular date, for the current year found with DateTimeFormat()
  • DateTimeAdd() will add or subtract from this date a particular interval say, +1 year or -1 year

If instead you want to/are more comfortable, working with these functions in equivalent dedicated transformers rather than writing out date/time formulae, have a look at:

  • DateTimeStamper
  • DateTimeConvertor
  • DateTimeCalculator
View original
Did this help you find an answer to your question?

1 reply

bwn
Evangelist
Forum|alt.badge.img+26
  • Evangelist
  • Best Answer
  • December 20, 2019

Have a look at the Date/Time functions help here:

https://docs.safe.com/fme/html/FME_Desktop_Documentation/FME_ReadersWriters/!Transformer_Parameters/Date-Time-Functions.htm

The particular functions to consider are:

  • DateTimeNow() to generate the current datetimestamp, which has in it the current year
  • DateTimeFormat() to extract the current Year with format %Y as the formatter
  • DateTimeParse() to create a datetimestamp for a particular date, for the current year found with DateTimeFormat()
  • DateTimeAdd() will add or subtract from this date a particular interval say, +1 year or -1 year

If instead you want to/are more comfortable, working with these functions in equivalent dedicated transformers rather than writing out date/time formulae, have a look at:

  • DateTimeStamper
  • DateTimeConvertor
  • DateTimeCalculator

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings