To Timestamp

Data Type Formatting Function

Description

Converts a string to a timestamp according to the given format.

Click here to navigate to the PostgreSQL docs page for this syntax.

The function TO_TIMESTAMP() is supported on Snowflake, but some formats may fail or behave differently in Snowflake.

Grammar Syntax

TO_TIMESTAMP( string, format )

Sample Source Patterns

PostgreSQL

SELECT
   TO_TIMESTAMP('12:00:00', 'HH:MS:SSSSS'),
   TO_TIMESTAMP('12:00:00 A.M.', 'HH:MS:SS A.M.'),
   TO_TIMESTAMP('2025-12-14 12:00:00', 'YYY-MONTH-DAY HH:MS:SS')

Snowflake

SELECT
   TO_TIMESTAMP('12:00:00', 'HH:MS:SSSSS'),    /*** MSC-INFORMATION - MSCINF0043 - THE CURRENT TO_TIMESTAMP FORMAT MAY HAVE A DIFFERENT BEHAVIOR IN SNOWFLAKE. ***/
   TO_TIMESTAMP('12:00:00 A.M.', 'HH:MS:SS A.M.'),    /*** MSC-INFORMATION - MSCINF0043 - THE CURRENT TO_TIMESTAMP FORMAT MAY HAVE A DIFFERENT BEHAVIOR IN SNOWFLAKE. ***/
   TO_TIMESTAMP('2025-12-14 12:00:00', 'YYY-MONTH-DAY HH:MS:SS')    /*** MSC-INFORMATION - MSCINF0043 - THE CURRENT TO_TIMESTAMP FORMAT MAY HAVE A DIFFERENT BEHAVIOR IN SNOWFLAKE. ***/

And the following cases are fully supported in Snowflake.

PostgreSQL

SELECT
  TO_TIMESTAMP( '2023-01-20 12:31:12.66', 'YYYY-MM-DD HH12:MI:SS'),
  TO_TIMESTAMP( '23-01-20', 'YY-MM-DD'),
  TO_TIMESTAMP( '17:31:12.66', 'HH24:MI:SS.FF2')

Snowflake

SELECT
  TO_TIMESTAMP( '2023-01-20 12:31:12.66', 'YYYY-MM-DD HH12:MI:SS'),
  TO_TIMESTAMP( '23-01-20', 'YY-MM-DD'),
  TO_TIMESTAMP( '17:31:12.66', 'HH24:MI:SS.FF2')

Snowflake supports the following formats:

Format ElementDescription

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

FF{x}

Seconds with {x} precision between 1-9

Last updated