snowflake-cloud-data-platformto-timestamp

to_timesamp converting month to different month


Any idea why snowflake to_timestamp is converting February month to January?

    SELECT to_timestamp(to_char('2022-02-02 08:01:29 AM'),'YYYY-MM-DD HH12:MM:SS AM');
    -- 2022-01-02 08:00:29.000

Solution

  • MM represent month when you convert to char , you should use MI for minute in snowflake, I assume the issue comes from there :

    SELECT to_timestamp(to_char('2022-02-02 08:01:29 AM','YYYY-MM-DD HH12:MI:SS AM'));