Formula to determine end of month dates

I have a database where different staff will need to post expenses incurred during a given pay cycle period. For us that falls on the 15th and the last day of the month.

For a different project that uses a week ending date of Fridays, I was able to find this piece of code that I use on the “default value” of the date field to set it to the current Friday.

Friday := 6;

date := @Today;

dayNumber := @Weekday(date);

@If(dayNumber=Friday; date; @Adjust(date; 0; 0; (Friday - dayNumber);0;0;0))

I added this piece in the input validation to make sure that if it’s changed it still falls on a Friday.

Friday := 6;

@If(@Weekday(WeekEnding) = Friday; @Success; @Failure(“The week ending date must be a Friday. Please select a new date.”))

I’m wondering if there is any to do something similar, but have it automatically determine the next 15th or end of month date. Or at least validate that the end of month date is actually the last day of month. I can probably figure it out for the 15th but wouldn’t know where to begin for the other piece.

Subject: Formula to determine end of month dates

Paul,

I don’t have my client… but something like

tmp := @adjust( @now;;1) 'go forward to the next month

tmp1 := @date( @year( tmp);@month( tmp);1) 'first day of next month

lastDayOfMonth := @adjust( tmp1;0;0;-1) 'goes back one day

John