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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Day of the week

Status
Not open for further replies.

kolkern

Programmer
Aug 13, 2004
3
US
I need to retrieve day of the week (*Mon, *Thu, *Wed and etc.) Is anybody know how to do this???
 
Also

C/Exec sql
C+ Set :DayOfWeek = DayOfWeek( MyDate )
C/End-exec

But SQL is involved.
 
You don't even need a service pgm> (Spacing adjusted)


D CheckDate S D
D DayOfWeek S 1S 0
D* (0=Sunday, 1=Monday, ... 6=Saturday)

C Eval DayOfWeek = %REM (%DIFF(Checkdate:
C %DATE('1899-12-31'):*D):7)
 
arrow483,
I think you have forgotten to show the results when Checkdate is before 1899-12-31.
Code:
/free
   DayOfWeek = %REM( %DIFF( Checkdate: %DATE( '1899-12-31' ) :*D ):7 ); 
[COLOR=red yellow]
   if DayOfWeek < 1;
     DayOfWeek = DayfWeek + 7;
   endif;
[/color]

Also, You could have the comparison date against 0001-01-07 (yes, it was a Sunday %-)) to get rid of this last test.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top