Skip to main content
Solved

Concatenate day with calculate month and year

  • December 22, 2019
  • 1 reply
  • 104 views

Hi there,

I am calculating the current and previous regulatory start and end years dates. For instance, the regulatory year starts from first May of every year and ends on the last day of April next year. So for the current year regulatory year period would be from 1-05-2019 to 30-04-2020. For the previous year, it would be 1-05-2018 to 30-04-2019.

I am using following code to calculate the start and end of the year:

Current Year Start : @DateTimeFormat(@DateTimeAdd(@DateTimeNow(),-P8M),%B %Y)

Current Year End: @DateTimeFormat(@DateTimeAdd(@DateTimeNow(),P3M),%B %Y)

Previous Year Start: @DateTimeFormat(@DateTimeAdd(@DateTimeNow(),-P20M),%B %Y)

Previous Year End: @DateTimeFormat(@DateTimeAdd(@DateTimeNow(),-P9M),%B %Y)

 

With the above code, the day is missing. If I use %d, it starts the day with reference to the current day. I don't know how to get the end or start day of the calculated months. So I decided to concatenate the hardcoded day with the above calculated months.

The problem I am facing is not sure how to get or concatenate the day in the above-calculated fields of months and years. Any help would be really appreciated.

 

Best answer by takashi

This screenshot illustrates an example of calculating start/end date of a fiscal year which today belongs to. Assuming that a fiscal year is from May 1 to the next April 30.

A date/time value is treated as just a string in FME translation processes. You can just concatenate elements of a date/time (i.e. year, month, day, hour, minutes, second) to create a required date/time value, and a date/time string formatted in Standard FME Date/Time Format can be calculated using FME Date/Time Functions. Finally you can change its format with the DateTimeConverter if necessary.

View original
Did this help you find an answer to your question?

1 reply

takashi
Influencer
  • Best Answer
  • December 22, 2019

This screenshot illustrates an example of calculating start/end date of a fiscal year which today belongs to. Assuming that a fiscal year is from May 1 to the next April 30.

A date/time value is treated as just a string in FME translation processes. You can just concatenate elements of a date/time (i.e. year, month, day, hour, minutes, second) to create a required date/time value, and a date/time string formatted in Standard FME Date/Time Format can be calculated using FME Date/Time Functions. Finally you can change its format with the DateTimeConverter if necessary.


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