Home > Software engineering >  How to convert a datetime ''May 30 2022 9:30PM" to this "2022-05-30 21:30:00&quo
How to convert a datetime ''May 30 2022 9:30PM" to this "2022-05-30 21:30:00&quo

Time:07-06

I have a date column in text format of "May 30 2022 9:30PM" and it needs to convert to "2022-05-30 21:30:00" in Snowflake SQL

I tried below SQL and its not working.

SELECT cast('May 30 2022 9:30PM' as datetime);
    

CodePudding user response:

For Snowflake, try the following:

select to_timestamp_ntz('May 30 2022 9:30PM', 'MON DD YYYY HH12:MIAM');

Reference: https://docs.snowflake.com/en/sql-reference/functions-conversion.html

  • Related