Skip to main content

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

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

Example:

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

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!