DAYS
The DAYS function returns an integer representation of a date.
- expression
- An expression that returns a value of one of the following built-in
data types: a date, a timestamp, a character string, or a graphic
string.
If expression is a character or graphic string, its value must be a valid string representation of a date or timestamp. For the valid formats of string representations of dates and timestamps, see String representations of datetime values.
The result of the function is a large integer. If the argument can be null, the result can be null; if the argument is null, the result is the null value.
The result is 1 more than the number of days from January 1, 0001 to D, where D is the date that would occur if the DATE function were applied to the argument.
Examples
- Using the PROJECT table, set the host variable EDUCATION_DAYS
(INTEGER) to the number of elapsed days (PRENDATE - PRSTDATE) estimated
for the project (PROJNO) ‘IF2000'.
Results in EDUCATION_DAYS being set to 396.SELECT DAYS(PRENDATE) - DAYS(PRSTDATE) INTO :EDUCATION_DAYS FROM PROJECT WHERE PROJNO = 'IF2000'
- Using the PROJECT table, set the host variable TOTAL_DAYS (INTEGER)
to the sum of elapsed days (PRENDATE - PRSTDATE) estimated for all
projects in department (DEPTNO) ‘E21'.
Results in TOTAL_DAYS being set to 1584.SELECT SUM(DAYS(PRENDATE) - DAYS(PRSTDATE)) INTO :TOTAL_DAYS FROM PROJECT WHERE DEPTNO = 'E21'