TO_TIMESTAMP_LTZ

functionsupportedCore SQL functions

docs.snowflake.com ↗

Conversion functionsDate & time functions

Converts an input expression into the corresponding timestamp: - TO_TIMESTAMP_LTZ (timestamp with local time zone) - TO_TIMESTAMP_NTZ (timestamp with no time zone) - TO_TIMESTAMP_TZ (timestamp with time zone) Note TO_TIMESTAMP maps to one of the other timestamp functions, based on the TIMESTAMP_TYPE_MAPPING session parameter. The parameter default is TIMESTAMP_NTZ, so TO_TIMESTAMP maps to TO_TIMESTAMP_NTZ by default.

Syntax

supportedpartialnot supportednot scored

timestampFunction ( <numeric_expr> [ , <scale> ] )

timestampFunction ( <date_expr> )

timestampFunction ( <timestamp_expr> )

timestampFunction ( <string_expr> [ , <format> ] )

timestampFunction ( '<integer>' )

timestampFunction ( <variant_expr> )

Where

timestampFunction ::=
    TO_TIMESTAMP | TO_TIMESTAMP_LTZ | TO_TIMESTAMP_NTZ | TO_TIMESTAMP_TZ

Parameters

NameRequiredDescription
numeric_exprrequiredA number of seconds (if scale = 0 or is absent) or fractions of a second (e.g. milliseconds or nanoseconds) since the start of the Unix epoch (1970-01-01 00:00:00 UTC). If a non-integer decimal expression is input, the scale of the result is inherited.
date_exprrequiredA date to be converted into a timestamp.
timestamp_exprrequiredA timestamp to be converted into another timestamp (e.g. convert TIMESTAMP_LTZ to TIMESTAMP_NTZ).
string_exprrequiredA string from which to extract a timestamp, for example '2019-01-31 01:02:03.004'.
'integer'requiredAn expression that evaluates to a string containing an integer, for example '15000000'. Depending on the magnitude of the string, it can be interpreted as seconds, milliseconds, microseconds, or nanoseconds. For details, see the Usage Notes.
variant_exprrequiredAn expression of type VARIANT. The VARIANT must contain one of the following: A string from which to extract a timestamp. A timestamp. An integer that represents the number of seconds, milliseconds, microseconds, or nanoseconds. A string containing an integer that represents the number of seconds, milliseconds, microseconds, or nanoseconds. Although TO_TIMESTAMP accepts a DATE value, it does not accept a DATE inside a VARIANT.
formatoptionalFormat specifier (only for string_expr). For more information, see Date and time formats in conversion functions. The default value is the current value of the TIMESTAMP_INPUT_FORMAT parameter (default AUTO).
scaleoptionalScale specifier (only for numeric_expr). If specified, defines the scale of the numbers provided. For example: For seconds, scale = 0. For milliseconds, scale = 3. For microseconds, scale = 6. For nanoseconds, scale = 9. Default: 0

Returns

The data type of the returned value is one of the TIMESTAMP data types. By default, the data type is TIMESTAMP_NTZ. You can change this by setting the session parameter TIMESTAMP_TYPE_MAPPING. If the input is NULL, then the result is NULL.

Usage notes

See also