Home > Blockchain >  Convert 'yyyymmddhhmmss' to MM/DD/YYYY HH:MM (AM/PM) in Snowflake
Convert 'yyyymmddhhmmss' to MM/DD/YYYY HH:MM (AM/PM) in Snowflake

Time:03-01

I would like to convert a String containing values in the format yyyymmddhhmmss to MM/DD/YYYY HH:MM (AM or PM) in Snowflake. The String contains time in UTC format. Also would like the final output to be in CST timezone.

Eg of String : 20220120035900

Expected output : 01/20/2022 03:59:00

Appreciate the help!

CodePudding user response:

Please check below select try_to_timestamp('20220120035900', 'YYYYMMDDHHMISS');

enter image description here

UTC to CST:

SELECT try_to_timestamp('20220120035900', 'YYYYMMDDHHMISS') as t_str,
    t_str::timestamp_ntz as UTC_tz,
    convert_timezone('UTC','America/Chicago', UTC_tz) chicago_time;
  • Related