Resolved How to Get End Date of a Month

Raj2010

New Member
Hi All,

I Am using 10.2b Windows XP 2002.

My Question is if i give date = today. then how can i find End Date of a month?

IF I GIVE I_DATE = TODAY.
THEN I NEED TO GET
I_END_DATE = 09/30/2013.

Is there any function to get End Date?

Thanks in advance.
Raj(new bee)
 

Osborne

Active Member
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.
 

rzr

Member
you could, also, get to first day of that month then go back by 1 day and then add one month on it.
check the help for ADD-INTERVAL()
 

whwar9739

Member
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.
 

TomBascom

Curmudgeon
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.

Do you ever run it in December?
 

whwar9739

Member
Do you ever run it in December?
Snap you caught me. Should be an easy mod.

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) + IF MONTH(i-date) = 12 THEN 1 ELSE 0).
i-eom = i-eom - 1.

My bad, thanks for the correct Tom.
 

TomBascom

Curmudgeon
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.

This one is really clever. In a good way. I like it :)
 
Top