How to bring the last day of the month?

Doh! Of course, makes total sense. :exploding_head:

1 Like
var1.datetime.addMonths(1).formatDate("yyyy-MM-01").addDays(-1)

@George expression works great for every month except february.

What does that mean? What happens when it’s February?

The expression should be a little different to work for all conditions:

var1.datetime.formatDate("yyyy-MM-01").addMonths(1).addDays(-1)

If you first add a month it can go wrong if you do that for example on 30 January, it will then go to March which is wrong. It does this because the formatter just add 1 to the month part of the date making it 30 February which is invalid and the date object will then automatically convert that to 1/2 March.

2 Likes

in server action use formatDate(“yyyy-MM-t”)