Problem subtracting months on the server side - Bug Report from aschoijett #2021-1-2_13-8-9

OS info

Problem description

I think there is a problem in the way .addDates() works when trying to subtract a month from a date.

I’m trying to use this function in a server action API.
I’m passing a date (let’s call it mydate) and want to obtain a new date (let’s call it newdate) that is one month earlier.

The code view in the server action API looks like this:
Set Value newdate = {{$_GET.mydate.dateAdd(‘months’, -1).formatDate(‘yyyy-MM-dd’)}}

If mydate = 2021-01-31, newdate becomes 2020-12-31, as one would expect.

If, however, mydate = 2020-12-31, newdate becomes 2020-12-01 instead of 2020-11-30

If mydate = 2020-12-30, then newdate is set to 2020-11-30
Is my expectation on how to use the dateAdd() wrong or there is a bug in this function?

Many thanks,

Alex

Community Page
Last updated: