TIMESTAMP

Click to skip syntax diagram
Read syntax diagramSkip visual syntax diagram>>-TIMESTAMP--(--expression-1--+-----------------+--)----------><
                               '-,--expression-2-'
 

The TIMESTAMP function returns a timestamp from its argument or arguments.

expression-1
If only one argument is specified, the argument must be an expression that returns a value of one of the following built-in data types: a timestamp, a character string, or a graphic string. If expression-1 is a character or graphic string, it must not be a CLOB or DBCLOB and its value must be one of the following:

If both arguments are specified, the first argument must be an expression that returns a value of one of the following built-in data types: a date, a character string, or a graphic string. If expression-1 is a character or graphic string, it must not be a CLOB or DBCLOB and its value must be a valid string representation of a date.

expression-2
The second argument must be an expression that returns a value of one of the following built-in data types: a time, a character string, or a graphic string.

If expression-2 is a character or graphic string, it must not be a CLOB or DBCLOB and its value must be a valid string representation of a time. For the valid formats of string representations of times, see String representations of datetime values.

The result of the function is a timestamp. If either argument can be null, the result can be null; if either argument is null, the result is the null value.

The other rules depend on whether the second argument is specified:

When a string representation of a date, time, or timestamp 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 timestamp value.

When a string representation of a date, time, or timestamp 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 timestamp value.

Note

Syntax alternatives: If only one argument is specified, the CAST specification should be used for maximal portability. For more information, see CAST specification.

Example