The date/time functions do the following:
Each date/time function is followed by an argument enclosed in parentheses. The following example lists the projects, by number, of each project scheduled to begin in 1990. It does this by applying the YEAR date/time function to the STARTD column of the Q.PROJECT table.
This query:
SELECT PROJNO, STARTD, ENDD, TIMESTAMP FROM Q.PROJECT WHERE YEAR(STARTD) = 1998
Produces this report:
PROJNO STARTD ENDD TIMESTAMP ------ ---------- ---------- -------------------------- 1409 1998-06-15 1999-12-31 1996-03-13-09.12.57.149572 1410 1998-09-29 2000-03-31 1996-03-13-12.18.23.402917
Date/time functions (see Table 1, following) can be used wherever an expression can be used. The first or only argument of each of these functions is an expression giving the value to be manipulated.
Function | Argument | Result |
---|---|---|
DATE | Date, timestamp, or string representation of a date | Date |
TIME | Time, timestamp, or string representation of a time | Time |
TIMESTAMP | Timestamp, string representation of timestamp, or a date or string representation of a date and a time or string representation of a time | Timestamp |
DAY, MONTH, or YEAR | Date or timestamp, or date duration | Day, month, or year part |
HOUR, MINUTE, or SECOND | Time or timestamp, or time duration | Hour, minute, or second part |
MICROSECOND | Timestamp | Microsecond part |
DAYS | Date, timestamp, or string representation of a date | Days since Dec 31, 0000 |
CHAR | Date or time and the specified date/time output format | String representation in specified date/time format. If format is not specified, ISO format will be returned. |