Previous Next

WEEKDAY function
Evaluates a date expression and returns the day of the week as an INTEGER value from 1 (Sunday) to 7 (Saturday) for that date.
Syntax 
 
WEEKDAY ( date )
 
WEEKDAY ( datetime-expression )
date
A date expression for which you want the day of the week.
datetime-expression
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.
Example 
This procedure tells you the day of the week that you were born and how many days old you are:
 
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.
See also 
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

Previous Next
© 2013 Progress Software Corporation and/or its subsidiaries or affiliates.