5 pts.
 Last Day of Month
Is there a routine to arrive at the exact last day of the month? *Month doesn't do it.

Software/Hardware used:
ASKED: July 1, 2008  5:02 PM
UPDATED: June 7, 2010  4:32 AM

Answer Wiki:
<pre> * Find the first day of month / last day of month D StrDate S D D EndDate S D /FREE StrDate = %date(%subst(%char(%date()):1:8) + '01':*ISO); EndDate = StrDate + %months(1) - %days(1); /END-FREE </pre> ---------------------------------------------- I keep these calculations handy, but they can be converted into procedures easily <pre> d PriorMonthBegin... d s d d PriorMonthEnd s d d MonthBegin s d d MonthEnd s d *Mon = 0 ... Sun = 6 d DayOfWeek s 1p 0 d WeekDay s n d WeekEnd s n PriorMonthBegin = %date() - %months(1) - %days(%subdt(%date() - %months(1):*days)) + %days(1); PriorMonthEnd = %date() - %days(%subdt(%date():*days)); MonthBegin = %date() - %days(%subdt(%date():*days)) + %days(1); MonthEnd = %date() + %months(1) - %days(%subdt(%date() + %months(1):*days)); DayOfWeek = %rem(%diff(%date():d'0001-01-01':*days):7); WeekDay = %rem(%diff(%date():d'0001-01-01':*days):7) < 5; WeekEnd = %rem(%diff(%date():d'0001-01-01':*days):7) > 4; </pre> Kevin - <a href="http://www.aresgrp.com">Affiliated</a> ======================================================= If you are current with your OS, you can use the SQL LAST_DAY(CURRENT DATE) function. It's not available for CL of course, but REXX can access it and report the result back out. Tom
Last Wiki Answer Submitted:  June 7, 2010  4:32 am  by  TomLiotta   110,115 pts.
All Answer Wiki Contributors:  TomLiotta   110,115 pts. , BigKat   7,205 pts. , graybeard52   3,115 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

// another way to get just the last day of this month
EndDate = %date() + %month(1) – %subdt(%date() + %month(1):*days);

 3,115 pts.

 

ha – Great minds think alike, huh Graybeard52?

 7,205 pts.

 

Must be the facial hair !

 3,115 pts.

 

I think Graybeard and BigKat are the same person, Martin.

Martin? Martin?

Yikes! You are ALL the same hairy person!

Sloopy, after a long lunch….

 2,195 pts.

 

Hey Sloopy,

Was that a long liquid lunch?

Cheers,

Martin.

 23,625 pts.

 

hmm…

my picture makes me look like the MCP in the movie TRON. :-)

 7,205 pts.

 

Yes, Martin.

Otherwise I would not post such stuff about three very large men with beards….

 2,195 pts.