TO_DATE
Date function
Description
TO_DATE converts a date represented by a character string to a DATE data type. (Redshift SQL Language Reference TO_DATE function)
This function is fully supported in Snowflake.
For more information about quoted identifiers in functions, click here.
Grammar Syntax
Sample Source Patterns
Input Code:
Output Code:
Known Issues
The query
SELECT TO_DATE('20010631', 'YYYYMMDD')
fails in Snowflake because June has only 30 days, and Snowflake'sTO_DATE
does not adjust invalid dates automatically, unlike Redshift'sTO_DATE
withis_strict
set to false, which would convert it to July 1. To avoid errors with invalid date strings, you can useTRY_TO_DATE
, which returnsNULL
if the conversion fails. This allows for smoother query execution and easier identification of invalid dates.
Related EWIs
SSC-FDM-RS0004: Invalid dates will cause errors in Snowflake.
SSC-EWI-PG0005: Date or time format is not supported in Snowflake.
SSC-FDM-0032: Parameter is not a literal value, transformation could not be fully applied
Last updated