I_END_DATE = (DATE(MONTH(I_DATE),28,YEAR(I_DATE)) + 4)
- DAY(DATE(MONTH(I_DATE),28,YEAR(I_DATE)) + 4).
DISPLAY I_END_DATE.
DEF VAR i-date AS DATE NO-UNDO.
DEF VAR i-eom AS DATE NO-UNDO.
i-date = somedate.
i-eom = DATE(MONTH(i-date) + 1, 1, YEAR(i-date)).
i-eom = i-eom - 1.
Real simple code, has worked flawlessly for me in the past:
Code:DEF VAR i-date AS DATE NO-UNDO. DEF VAR i-eom AS DATE NO-UNDO. i-date = somedate. i-eom = DATE(MONTH(i-date) + 1, 1, YEAR(i-date)). i-eom = i-eom - 1.
Nice thing about this code is that Progress will handle leap years and 30 or 31 day months.
Snap you caught me. Should be an easy mod.Do you ever run it in December?
DEF VAR i-date AS DATE NO-UNDO.
DEF VAR i-eom AS DATE NO-UNDO.
i-date = somedate.
i-eom = DATE(MONTH(i-date) + 1, 1, YEAR(i-date) + IF MONTH(i-date) = 12 THEN 1 ELSE 0).
i-eom = i-eom - 1.
I do not think a built-in function exists but you can easily write your own, and something like this will give a month end date from a starting date:
Code:I_END_DATE = (DATE(MONTH(I_DATE),28,YEAR(I_DATE)) + 4) - DAY(DATE(MONTH(I_DATE),28,YEAR(I_DATE)) + 4). DISPLAY I_END_DATE.
Yes, I have found it really useful, although cannot take the credit as found it posted somewhere else.This one is really clever. In a good way. I like it![]()