TRY_TO_DATE

functionsupportedCore SQL functions

docs.snowflake.com ↗

Conversion functionsDate & time functions

A special version of the TO_DATE function that performs the same operation (i.e. converts an input expression to a date), 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.

Syntax

supportedpartialnot supportednot scored

TRY_TO_DATE( <string_expr> [, <format> ] )
TRY_TO_DATE( '<integer>' )

Parameters

NameRequiredDescription
string_exprrequiredString from which to extract a date. For example: '2024-01-31'.
'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 for this function.
formatoptionalDate format specifier for string_expr or AUTO, which specifies that Snowflake should automatically detect the format to use. For more information, see Date and time formats in conversion functions. The default is the current value of the DATE_INPUT_FORMAT session parameter (default AUTO).

Returns

The data type of the returned value is DATE.

Usage notes

See also

Referenced by