Evaluates a date expression and returns the day of the week as an INTEGER value from 1 (Sunday) to 7 (Saturday) for that date.
A date expression for which you want the day of the week.
An expression that evaluates to a DATETIME or DATETIME-TZ. The WEEKDAY function returns the weekday of the date part of the DATETIME or DATETIME-TZ value.
This procedure tells you the day of the week that you were born and how many days old you are:
r-wkday.p
DEFINE VARIABLE birth-date AS DATE NO-UNDO LABEL "Birth Date". DEFINE VARIABLE daynum AS INTEGER NO-UNDO. DEFINE VARIABLE daylist AS CHARACTER NO-UNDO FORMAT "x(9)" INITIAL "Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday". DEFINE VARIABLE dayname AS CHARACTER NO-UNDO LABEL "Day You Were Born". DEFINE VARIABLE daysold AS INTEGER NO-UNDO LABEL "Days Since You Were Born". REPEAT: SET birth-date. ASSIGN daynum = WEEKDAY(birth-date) dayname = ENTRY(daynum, daylist) daysold = TODAY - birth-date. DISPLAY dayname daysold. END. |
ADD-INTERVAL function, DATE function, DATE-FORMAT attribute, DATETIME function, DATETIME-TZ function, DAY function, ETIME function, INTERVAL function, ISO-DATE function, MONTH function, MTIME function, NOW function, TIME function, TIME-SOURCE attribute, TIMEZONE function, TODAY function, YEAR function, YEAR-OFFSET attribute