Last Day of Month

5 pts.
Tags:
AS/400 date format
CLLE
Is there a routine to arrive at the exact last day of the month? *Month doesn't do it.

Answer Wiki

Thanks. We'll let you know when a new response is added.

<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

Discuss This Question: 7  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • graybeard52
    // another way to get just the last day of this month EndDate = %date() + %month(1) - %subdt(%date() + %month(1):*days);
    3,115 pointsBadges:
    report
  • BigKat
    ha - Great minds think alike, huh Graybeard52?
    8,330 pointsBadges:
    report
  • graybeard52
    Must be the facial hair !
    3,115 pointsBadges:
    report
  • Sloopy
    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 pointsBadges:
    report
  • Gilly400
    Hey Sloopy, Was that a long liquid lunch? Cheers, Martin.
    23,730 pointsBadges:
    report
  • BigKat
    hmm... my picture makes me look like the MCP in the movie TRON. :-)
    8,330 pointsBadges:
    report
  • Sloopy
    Yes, Martin. Otherwise I would not post such stuff about three very large men with beards....
    2,195 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following