Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date fields and Days

Status
Not open for further replies.

Fooch

Programmer
Dec 19, 2005
63
US
This may be a long shot, but can RPG determine the day(Thursday, Saturday, Etc.) from a given date field? To like determine it is a weekend or something?
 
There is no direct BIF, but it easy to do.

D CheckDate S D
D DayOfWeek 1S 0
D* (0=Sunday, 1=Monday, ... 6=Saturday)
C
C Eval DayOfWeek = %REM (%DIFF(Checkdate:
C %DATE('1752-12-31'):*D):7)
 
Awesome, thanks. What is the reason for THAT date? 12/31/1752
 
(a), it's a Sunday, and (b), it's the year that the Gregorian calendar was adopted in English-speaking countries in place of the old Julian calendar. Because the AS/400's dates do not skip any days (there was a gap of 11 days between them in 1752), any date before 1752-09-14 will not have the correct day of the week.

See
Sumptum fac donec consumptus sis.

-- my wife's motto
 
You can use any Sunday you like (well, after the short year). Some people prefer a date in 1900. I just like 1752.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top