DAYS
DAYS returns a FIXED BINARY(31,0) value that is the number of days (in Lilian format) corresponding to the date d.
- d
- String expression representing a date. If omitted, it is assumed
to be the value returned by DATETIME().
The value for d must have computational type and should have character type. If not, d is converted to character.
- p
- One of the supported date/time patterns. If omitted, it is assumed
to be the value 'YYYYMMDDHHMISS999'.
p must have computational type and should have character type. If not, it is converted to character.
- w
- An integer expression that defines a century window to be used
to handle any two-digit year formats.
- If the value is positive, such as 1950, it is treated as a year.
- If negative or zero, the value specifies an offset to be subtracted from the current, system-supplied year.
- If omitted, w defaults to the value specified in the WINDOW compile-time option.
Example
dcl Date_format value ('MMDDYYYY') char;
dcl Todays_date char(length(Date_format));
dcl Sep2_1993 char(length(Date_format));
dcl Days_of_July4_1993 fixed bin(31);
dcl Msg char(100) varying;
dcl Date_due char(length(Date_format));
Todays_date = datetime(date_format); /* e.g. 06161993 */
Days_of_July4_1993 = days('07041993','MMDDYYYY');
Sep2_1993 = daystodate(days_of_July4_1993 + 60, Date_format);
/* 09021993 */
Date_due = daystodate(days() + 60, Date_format);
/* assuming today is July 4, 1993, this would be Sept. 2, 1993 */
Msg = 'Please pay amount due on or before ' ∥
substr(Date_due, 1, 2) ∥ '/' ∥
substr(Date_due, 3,2) ∥ '/' ∥
substr(Date_due, 5);
The allowed patterns are listed in Table 2. For an explanation of the Lilian format, see Date/time built-in functions.