Microflow - addMonths doesnt recognize leap year?

0
Hi – I’m using addMonths in a “Change Variable” action that uses the following expression. What I’m finding is, if the input variable $Dt_Instance is 1/30/2020, then the expression below returns 2/28/2020 (not 2/29/2020)? Do we know why that is? It seems the expression below is not recognizing leap years?   trimToDaysUTC(addMonthsUTC(trimToDaysUTC($Dt_Instance),1))
asked
3 answers
0

Not a sollution to why this is happening but did you try to use [%EndOfCurrentMonthUTC%]?

So addMonthsUTC([%EndOfCurrentMonthUTC%],1)

Regards,

Ronald

answered
0

Hello SL,

This is an interesting question. I don’t know if the result 2/28/2020 is right, but it is defendable.

But first, the expression is taking leap years into account. I tried adding one month to date 1/30/2020 and it returned 2/29/2020. So it knows about leap years.

Back to the original question. What does adding one month exactly mean? It is hard to define correctly. You started with 30/1/2020 (one day before the last day of January) and ended up with 28/2/2020 (one day before the last day of February). If you put it that way, the result sounds right to me. Adding one month, does that mean always adding 30 days, or does it mean adding 31 days, or something else? In your case it added 29 days, and that is the lenght of February 2020.

This subject can be debated for a long time. If you want more, I can for example recommend https://codeblog.jonskeet.uk/2010/12/01/the-joys-of-date-time-arithmetic/

Regards,

Paul

answered
0

Hi – in response to Ron’s, unfortunately, I cannot use the keyword endofcurrentmonth, but good thought and thank you!

answered