DATE scalar function
The DATE function returns a date from a value.
The schema is SYSIBM.
The special behavior of DATE with the Db2® compatibility features for Oracle applications is described in DATE data type based on TIMESTAMP(0).
-
expression
- An expression that returns a value of one of the following built-in
data types: DATE, TIMESTAMP, numeric, or character string that is
not a CLOB.
A value with a numeric data type must be a positive number with an integral value less than or equal to 3 652 059.
A character string must be a valid string representation of a date or timestamp or a string of length 7. If the value is a string of length 7, it must represent a valid date in the form yyyynnn , where yyyy are digits denoting a year, and nnn are digits between 001 and 366, denoting a day of that year.
In a Unicode database, if an expression returns a value of a graphic string data type, the value is first converted to a character string before the function is executed.
The result of the function is a DATE. If the argument can be null, the result can be null; if the argument is null, the result is the null value.
- If the argument is a DATE, TIMESTAMP, or valid string representation
of a date or timestamp:
- The result is the date part of the value.
- If the argument is a number:
- The result is the date that is n-1 days after January 1, 0001, where n is the integral part of the number.
- If the argument is a string with a length of 7:
- The result is the date represented by the string.
Examples
- Example 1: This example results in an internal representation
of '1988-12-25'.
DATE(RECEIVED)
- Example 2: This example results in an internal representation
of '1988-12-25'.
DATE('1988-12-25')
- Example 3: This example results in an internal representation
of '1988-12-25'.
DATE('25.12.1988')
- Example 4: This example results in an internal representation
of '0001-02-04'.
DATE(35)