Calculate the first and the last day of a month

0
Hello, I want to validate on an attribute based on the start and end date, the user should select for e.g. StartDate on the 1st of March and the 31st of March as the EndDate so this can be approved, if they selected the 1st of March as a StartDate and the EndDate 1st of April it should validate that the date should be from the first till the end of this month, how can I achieve that noting that I used the “ calendarMonthsBetween “ and it only works if the user enters from the 1st till the 1st of the next month Thanks!
asked
1 answers
1

In your expression, you can use date arithmetic something like this:

$endDate <= addMinutes(addMonths($startDate,1),-1)

This takes the start date, adds one month and then subtracts one minute.  Note that depending how precise you need to be, you could use addSeconds or addMilliseconds instead of AddMinutes.

answered