TO_TIMESTAMP()
function converts a string into a timestamp based on the provided format. It returns a TIMESTAMP WITH TIME ZONE
type.
TO_TIMESTAMP()
function is as follows:
source
: The date/time value to be converted. The value type is TIMESTAMP
(YYYY-MM-DD HH:MM:SS
).format
: The format of the input string. Pattern | Description | Detail |
---|---|---|
YYYY | Year (1-9999) | - The lowest possible value is 1 AD - 0001 is 1 - 1 is 1 |
MM | Month number (1–12) | - Up to 2 digits - 01 is 1 - 1 is 1 |
DD | Day of month (1–31) | - Up to 2 digits - 01 is 1 - 1 is 1 |
HH | Hour of day (1–12) | - Up to 2 digits - 01 is 1 - 1 is 1 |
HH12 | Hour of day (1–12) | - Up to 2 digits - 01 is 1 - 1 is 1 |
HH24 | Hour of day (0–23) | - Up to 2 digits - 01 is 1 - 1 is 1 |
MI | Minute (0–59) | - Up to 2 digits - 01 is 1 - 1 is 1 |
SS | Second (0–59) | - Up to 2 digits - 01 is 1 - 1 is 1 |
MS | Millisecond (0–999) | - Up to 3 digits - 001 is 1 millisecond - 1 is 100 milliseconds |
US | Microsecond (0–999999) | - Up to 6 digits - 000001 is 1 microsecond - 1 is 100000 milliseconds |
AM , am , PM or pm | Meridiem indicator | Without periods |
A.M. , a.m. , P.M. or p.m. | Meridiem indicator | With periods |
TO_TIMESTAMP()
function converts the provided string into a timestamp with the format YYYY-MM-DD HH24:MI
.
TO_TIMESTAMP()
function converts the provided string into a timestamp with the format MM-DD HH12:MI
.
TO_TIMESTAMP()
` function converts the provided string into a timestamp with the format YYYY-MM HH12:MI
with meridiem indicator (AM/PM).
Request 1
TO_TIMESTAMP()
function converts the provided string into a timestamp with YYYY-MM-DD HH24:MI:SS.MS.US
format.
TO_TIMESTAMP()
function converts the provided string into a timestamp with YYYY-MM-DD HH24:MI:SS.MS
format.