Previous Next

DAY function
Evaluates a date expression and returns a day of the month as an INTEGER value from 1 to 31, inclusive.
Syntax 
 
DAY ( date )
 
DAY ( datetime-expression )
date
An expression whose value is a DATE.
datetime-expression
An expression that evaluates to a DATETIME or DATETIME-TZ. The DAY function returns the day of the month of the date part of the DATETIME or DATETIME-TZ value.
Example 
This procedure determines the date one year from a given date, allowing for leap years. You could simply determine a date 365 days later by adding 365 to the d1 variable, but that might not produce the correct result (for example, 1/1/92 + 365 days is 12/31/92).
 
DEFINE VARIABLE d1    AS DATE    NO-UNDO LABEL "Date".
DEFINE VARIABLE d2    AS DATE    NO-UNDO LABEL "Same date next year".
DEFINE VARIABLE d-day AS INTEGER NO-UNDO.
DEFINE VARIABLE d-mon AS INTEGER NO-UNDO.
 
REPEAT:
  SET d1.
  d-day = DAY(d1).
  d-mon = MONTH(d1).
  IF d-mon = 2 AND d-day = 29 THEN d-day = 28.
  d2 = DATE(d-mon,d-day,YEAR(d1) + 1).
  DISPLAY d2.
END.
See also 
ADD-INTERVAL function, DATE function, DATE-FORMAT attribute, DATETIME function, DATETIME-TZ function, ETIME function, INTERVAL function, ISO-DATE function, MONTH function, MTIME function, NOW function, TIME function, TIMEZONE function, TODAY function, WEEKDAY function, YEAR function, YEAR-OFFSET attribute

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