A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.snowflake.com/en/sql-reference/functions/try_to_timestamp below:

Website Navigation


TRY_TO_TIMESTAMP / TRY_TO_TIMESTAMP_*

Categories:

Conversion functions

TRY_TO_TIMESTAMP / TRY_TO_TIMESTAMP_*

A special version of TO_TIMESTAMP / TO_TIMESTAMP_* that performs the same operation (i.e. converts an input expression into a timestamp), but with error-handling support (i.e. if the conversion cannot be performed, it returns a NULL value instead of raising an error).

For more information, see Error-handling conversion functions.

Note

TRY_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 TRY_TO_TIMESTAMP maps to TRY_TO_TIMESTAMP_NTZ by default.

See also:

TO_TIMESTAMP / TO_TIMESTAMP_*

Syntax
timestampFunction ( <string_expr> [, <format> ] )
timestampFunction ( '<integer>' )

Copy

Where:

timestampFunction ::=
    TRY_TO_TIMESTAMP | TRY_TO_TIMESTAMP_LTZ | TRY_TO_TIMESTAMP_NTZ | TRY_TO_TIMESTAMP_TZ

Copy

Arguments

Required:

One of:

string_expr

A string that can be evaluated to a TIMESTAMP (TIMESTAMP_NTZ, TIMESTAMP_LTZ, or TIMESTAMP_TZ).

'integer'

An 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.

Optional:

format

Format specifier for string_expr or AUTO. For more information, see Date and time formats in conversion functions.

The default is the current value of the TIMESTAMP_INPUT_FORMAT session parameter (default AUTO).

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.

Usage notes Examples

This example uses TRY_TO_TIMESTAMP:

SELECT TRY_TO_TIMESTAMP('2024-01-15 12:30:00'), TRY_TO_TIMESTAMP('Invalid');

Copy

+-----------------------------------------+-----------------------------+
| TRY_TO_TIMESTAMP('2024-01-15 12:30:00') | TRY_TO_TIMESTAMP('INVALID') |
|-----------------------------------------+-----------------------------|
| 2024-01-15 12:30:00.000                 | NULL                        |
+-----------------------------------------+-----------------------------+

See TO_TIMESTAMP / TO_TIMESTAMP_* for examples that convert an input expression to a timestamp.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4