Casting from SQL Data Types to Date and Time Data Types

From InterBase

Go Up to Using CAST( ) to Convert Dates and Times


The following table shows the SQL data types from which the DATE, TIME, and TIMESTAMP data types can be cast.

CAST data type below TO data type at right

TIMESTAMP

DATE

TIME

SMALLINT

INTEGER

FLOAT

DOUBLE PRECISION

NUMERIC

DECIMAL

Error

Error

Error

VARCHAR(n)

CHAR(n)

CSTRING(n)

Succeeds if the string is in the following format:

YYYY-MM-DD HH:MM:SS.thou

Succeeds if the string is in the following format:

YYYY-MM-DD

Succeeds if the string is in the following format:

HH:MM:SS.thou

BLOB

Error

Error

Error

TIMESTAMP

Always succeeds

Succeeds: date portion of TIMESTAMP

Succeeds: time portion of TIMESTAMP

DATE

Succeeds: time portion of TIMESTAMP set to 0:0:0.0000

Always succeeds

Error

TIME

Succeeds: date portion of TIMESTAMP set to the base-0 date (17 November, 1858)

Error

Always succeeds

Advance To: