Oct 11, 2004 #1 kolkern Programmer Joined Aug 13, 2004 Messages 3 Location US I need to retrieve day of the week (*Mon, *Thu, *Wed and etc.) Is anybody know how to do this???
Oct 11, 2004 #2 rstitzel MIS Joined Apr 24, 2002 Messages 286 Location US I created a service program from some code that I found on the net. Here's the link: http://www.as400pro.com/TipsRPG13.htm#3 It also calculates Week Of Year. Hope this helps. Upvote 0 Downvote
I created a service program from some code that I found on the net. Here's the link: http://www.as400pro.com/TipsRPG13.htm#3 It also calculates Week Of Year. Hope this helps.
Oct 11, 2004 #3 Mercury2 Technical User Joined Feb 27, 2004 Messages 422 Location FR Also C/Exec sql C+ Set ayOfWeek = DayOfWeek( MyDate ) C/End-exec But SQL is involved. Upvote 0 Downvote
Oct 12, 2004 #4 arrow483 MIS Joined Mar 17, 2004 Messages 155 Location US 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) Upvote 0 Downvote
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)
Oct 12, 2004 #5 Mercury2 Technical User Joined Feb 27, 2004 Messages 422 Location FR 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. Upvote 0 Downvote
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.
Oct 13, 2004 #6 iSeriesCodePoet Programmer Joined Jan 11, 2001 Messages 1,373 Location US I just wrote up a quick subprocedure that should work. Feel free to use that or let me know of any bugs. iSeriesCodePoet iSeries Programmer/Lawson Software Administrator http://www.koldark.nethttp://www.spreadfirefox.com/?q=affiliates&id=2483&t=1 Upvote 0 Downvote
I just wrote up a quick subprocedure that should work. Feel free to use that or let me know of any bugs. iSeriesCodePoet iSeries Programmer/Lawson Software Administrator http://www.koldark.nethttp://www.spreadfirefox.com/?q=affiliates&id=2483&t=1