Casting from SQL Data Types to Date and Time Data Types
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 |
|
|
|
---|---|---|---|
|
Error |
Error |
Error |
|
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 |
|
Error |
Error |
Error |
|
Always succeeds |
Succeeds: date portion of |
Succeeds: time portion of |
|
Succeeds: time portion of |
Always succeeds |
Error |
|
Succeeds: date portion of |
Error |
Always succeeds |