url: http://itknowledgeexchange.techtarget.com/itanswers/day-of-week/
1)
DayOfWeek = %Subst(('Sunday Monday Tuesday WednesdayThursday Friday Saturday ' ):(((%Rem(%Diff(%Date():%Date(1900-01-07′):*D):7)+1)*9))-8:9);
每個item 9個字符。
2)
This is the code for a service program
H nomain
D Dayofweek Pr 1p 0
D inputdate d
D Dayname Pr 9
D inputdate d
* ====================================================================
* Dayofweek - Calculate day of the week from input date
* ====================================================================
P Dayofweek B Export
D Dayofweek Pi 1p 0
D workdate d
D Anysunday S d inz(d'1900-01-07')
D Worknum S 7 0
D Workday S 1p 0
C workdate Subdur anysunday worknum:*d
C worknum Div 7 worknum
C Mvr workday
C If workday <= *zero
C Return workday + 7
C Else
C Return workday
C EndIf
P Dayofweek E
* ====================================================================
* Dayname - Return name of week day from given date
* ====================================================================
P Dayname B Export
D Dayname Pi 9
D workdate d
D Namedata Ds
D data 63 inz('Monday Tuesday WednesdayThur+
D sday Friday Saturday Sunday')
D name 9 overlay(data:1) dim(7)
C Return name(dayofweek(workdate))
P Dayname E