Datetime operands

A date, time, or timestamp value is compatible with another value of the same type or any string expression that contains a valid string representation of the same type.

A DATE type is compatible with another DATE type or any string expression that contains a valid string representation of a date. A string representation is a value that is a built-in character string data type or graphic string data type. A string representation must not be a CLOB or DBCLOB and must have an actual length that is not greater than 255 bytes. The data type of the result is DATE.

A TIME type is compatible with another TIME type or any string expression that contains a valid string representation of a time. A string representation is a value that is a built-in character string data type or graphic string data type. A string representation must not be a CLOB or DBCLOB and must have an actual length that is not greater than 255 bytes. The data type of the result is TIME.

Start of changeA timestamp type is compatible with another timestamp type, a timestamp constant, or any string expression that contains a valid string representation of a timestamp. A string representation is a value that is a built-in character string data type or graphic string data type. A string representation must not be a CLOB or DBCLOB and must have an actual length that is not greater than 255 bytes. The data type of the result is a timestamp as determined in the following table.End of change

Start of change
Table 1. Result data types with datetime operands
One operand Other operand Data type of the result
TIMESTAMP(x) WITHOUT TIME ZONE TIMESTAMP(y) WITHOUT TIME ZONE TIMESTAMP(max(x,y)) WITHOUT TIME ZONE
TIMESTAMP(x) WITHOUT TIME ZONE CHAR(y) or VARCHAR(y) TIMESTAMP(x) WITHOUT TIME ZONE 1
TIMESTAMP(x) WITH TIME ZONE TIMESTAMP(y) WITH TIME ZONE TIMESTAMP(max(x,y)) WITH TIME ZONE
TIMESTAMP(x) WITH TIME ZONE CHAR(y) or VARCHAR(y) TIMESTAMP(x) WITH TIME ZONE
TIMESTAMP(x) WITH TIME ZONE TIMESTAMP(y) WITHOUT TIME ZONE TIMESTAMP(max(x,y)) WITH TIME ZONE
Note: If one operand is TIMESTAMP(x) WITHOUT TIME ZONE and the other operand is CHAR(y) or VARCHAR(y), the result data type is TIMESTAMP(x) WITHOUT TIME ZONE even if the string representation contains a time zone.
End of change

If both operands are in the same encoding scheme, the result is in that encoding scheme. Otherwise the result is in the application encoding scheme.