17
Views
8
Solved
Question
Application Type
Reactive
Service Studio Version
11.9.2 (Build 34232)

Hi

I am using add months builtin function.suppose I am entering 30th Dec 2020 and trying to add 1 month with help of add months built in function.and it returning proper output 30 th January 2021 but when I am passing 28th February 2021 and trying to add 1 month then it is returning 28 th March 2021 but it should be 30th March 2021.is it right behaviour?

MVP
Rank: #2
Solution

If you're goal is to get the last days of every month, you could take the first day of the next month, and subtract one day. So if you have a certain last day, add one day, add one month, then subtract one day, and so on.

If you want to have all 30th of all months except for February, you'll have to come up with a smarter algorithm, that is actually aware of February having 28 or 29 days. You could also try to see if the NewDate function turns 30 February into 28, and use that.

Rank: #70

Yes, March 28th is 1 month later than February 28th.

If you are looking to add 30 days you can use the AddDays built-in functionality.

Regards,
João

MVP
Rank: #2
Solution

If you're goal is to get the last days of every month, you could take the first day of the next month, and subtract one day. So if you have a certain last day, add one day, add one month, then subtract one day, and so on.

If you want to have all 30th of all months except for February, you'll have to come up with a smarter algorithm, that is actually aware of February having 28 or 29 days. You could also try to see if the NewDate function turns 30 February into 28, and use that.

Rank: #491

Yeah, it adds 1 month to the date you chose as start date, and 1 month = 30 days.

To get end of the date I think you should try your own function.

For example,