Search code examples
sqlcastingtype-conversionsnowflake-cloud-data-platformsnowflake-schema

How can i cast a date format to zulu format in snowflake?


I'm trying to convert all my date format to Zulu (ISO 8601) Format in my query

Need to convert 2022-03-17 to 2022-03-17T00:00:00Z

I'm only able to cast into TIMESTAMP_LTZ,TIMESTAMP_NTZ,TIMESTAMP_TZ

2020-03-17 00:00:00.000 +0100
2020-03-17 00:00:00.000
2020-03-17 00:00:00.000 +0100

Is there any way to do this?


Solution

  • This should give you want you want, assuming you are just trying to display the date in this specific format:

    SELECT TO_char('2022-03-17'::timestamp, 'YYYY-MM-DD"T"HH24:MI:SS"Z"');