Skip to main content
Question

Calculating 1st of the month from last day of the month

  • July 22, 2019
  • 2 replies
  • 126 views

Hi,

I'm trying to calculate the 1st the of the month using the end of the month date. Now I know the interval days for the months but I'm not sure how I can write this in FME.

I've written out in plain text of an example if statement-of what I need.

If end date month is equal to April,June,September,November then subtract P29D else if end date month is equal to January,March,May,July,August,October,December then subtract P30D else if end date month is equal to February then subtract P27D else if Feburary is in a leap year subtract P28D

Is there an elegant way of using the Date/Time functions to calculate the 1st of the month? or would I need to use an if statement?

I use an attribute called _endDate which is the end of the month.

Josh

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.

2 replies

david_r
Celebrity
  • 8394 replies
  • July 22, 2019

Why not simply extract the month and year part, then concatenate those with '01' as the day?

Example:

'28022019' -> '01' + '022019'

  • Author
  • 3 replies
  • July 22, 2019

Why not simply extract the month and year part, then concatenate those with '01' as the day?

Example:

'28022019' -> '01' + '022019'

I didn't think of that! It worked like a charm. Thanks!