To Char
Data Type Formatting Function
Description
Converts a timestamp/number to string according to the given format.
Click here to navigate to the PostgreSQL docs page for this syntax.
The function To_char() is supported on Snowflake, but some formats may fail or behave differently in Snowflake.
Grammar Syntax
Sample Source Patterns
Numeric Formatting
When a numeric format is present in the function, the EWI MSC-PG0012 will be added because this format may fail or have a different behavior. For more information, please refer to PostgreSQL Numeric Formatting.
PostgreSQL
Snowflake
Date/Time Formatting
PostgreSQL
Snowflake
And the following cases are fully supported in Snowflake.
PostgreSQL
Snowflake
Snowflake supports the following formats:
Format Element | Description |
---|---|
YYYY | Year (4 or more digits). |
YY | Last 2 digits of year. |
MM | Month number (01–12). |
MON | Month name (3 chars in English, localized lengths vary). |
DD | Day of month (01–31). |
DY | Day name (3 chars in English, localized lengths vary). |
HH24 | Hour of day (01–12). |
HH12 | Hour of day (00–23). |
FF1 | Tenth of second (0–9). |
FF2 | Hundredth of second (00–99). |
FF3 | Millisecond (000–999). |
FF4 | Tenth of a millisecond (0000–9999). |
FF5 | Hundredth of a millisecond (00000–99999). |
FF6 | Microsecond (000000–999999). |
Related EWIs
MSC-PG0012: THE CURRENT TO_CHAR NUMERIC FORMAT MAY FAIL OR HAVE A DIFFERENT BEHAVIOR IN SNOWFLAKE.
Last updated