Skip to main content
Solved

Dynamic calculation of year

  • December 20, 2019
  • 1 reply
  • 534 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
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.

1 reply

bwn
Evangelist
Forum|alt.badge.img+26
  • Evangelist
  • 562 replies
  • 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