The DATE function returns a date from a value.
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.
The other rules depend on the data type of the argument:
The result is the date part of the timestamp.
The result is that date.
The result is the date that is n-1 days after January 1, 0001, where n is the integral part of the number.
The result is the date represented by the string or the date part of the timestamp value represented by the string.
When a string representation of a date is SBCS data with a CCSID that is not the same as the default CCSID for SBCS data, that value is converted to adhere to the default CCSID for SBCS data before it is interpreted and converted to a date value.
When a string representation of a date is mixed data with a CCSID that is not the same as the default CCSID for mixed data, that value is converted to adhere to the default CCSID for mixed data before it is interpreted and converted to a date value.
When a string representation of a date is graphic data, that value is converted to adhere to the default CCSID for SBCS data before it is interpreted and converted to a date value.
Syntax alternatives: When the argument is a date, timestamp, or character string, the CAST specification should be used for maximal portability. For more information, see CAST specification.
SELECT DATE(RECEIVED) FROM IN_TRAY WHERE SOURCE = 'BADAMSON'
Results in a date data type with a value of '1988-12-25'.
SELECT DATE('1988-12-25') FROM SYSIBM.SYSDUMMY1
Results in a date data type with a value of '1988-12-25'.
SELECT DATE('25.12.1988') FROM SYSIBM.SYSDUMMY1
Results in a date data type with a value of '1988-12-25'.
SELECT DATE(35) FROM SYSIBM.SYSDUMMY1
Results in a date data type with a value of '0001-02-04'.
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.