DATE and DATETIME values can be reformatted in Snowflake using TO_CHAR, TO_DATE, CAST, and FORMAT parameters to display or convert dates in any needed pattern.
Use TO_CHAR(date_expression, 'format')
to turn a DATE, TIME, or TIMESTAMP into a string. Supply any valid Snowflake format mask, such as 'YYYY-MM-DD'
or 'DD Mon YYYY'
.
Wrap the string with TO_DATE('2024-06-15', 'YYYY-MM-DD')
or use CAST('15/06/2024' AS DATE FORMAT 'DD/MM/YYYY')
. Always pass the correct mask to avoid implicit-conversion errors.
YYYY
=four-digit year, YY
=two-digit year, MM
=month number, MON
=month abbreviation, DD
=day of month, HH24
=24-hour, MI
=minute, SS
=second, TZ
=time-zone.
Format the column directly in the SELECT: SELECT TO_CHAR(order_date, 'FMDay, DD Mon YYYY') AS friendly_date FROM Orders;
The FM
prefix removes leading zeros and padding spaces.
Supply the mask 'YYYY-MM-DD"T"HH24:MI:SS"Z"'
to TO_CHAR
. This is ideal when exporting data to APIs expecting strict ISO strings.
Snowflake supports the ALTER SESSION SET TIMEZONE
and ALTER SESSION SET DATE_OUTPUT_FORMAT
parameters. Set these before running queries to apply organization-wide formatting rules.
Always specify an explicit mask. Store dates as DATE/TIMESTAMP, never pre-formatted strings. Use TO_CHAR
only in the presentation layer, and document masks in shared collections.
Yes. Run ALTER SESSION SET DATE_OUTPUT_FORMAT = 'YYYY-MM-DD'
and Snowflake will emit dates in that style until the session ends.
Snowflake returns NULL
by default. Wrap the call with TRY_TO_DATE
to capture failures without exceptions.
Use TIMESTAMP_TZ columns and add "TZH:TZM"
in the format mask, e.g., TO_CHAR(event_ts, 'YYYY-MM-DD HH24:MI:SS TZH:TZM')
.