I am using an SQL Script to parse a json into a table using dbt. One of the cols had this date value: '2022-02-09T20:28:59+0000'. What would be the correct way to define iso date's data type in Snowflake?
Currently, I just used the date type like this in my dbt sql script:
JSON_DATA:"situation_date"::date AS MY_DATE
but clearly, dateisn't the correct one because later when I test it using select * , I get this error:
SQL Error [100040] [22007]: Date '2022-02-09T20:28:59+0000' is not recognized
so I need to know which Snowflake date data type or datetime type suits the best with this one
Correct pulling the "date from JSON" so not so clear cut:
gives the error:
Because the type of
data_from_jsonasVARIANTand the TO_DATE/TO_TIMESTAMP function expectTEXTso we need to cast to thatIf all your timezones are always
+0000you can just put that in the parse format (like exampledate_1), OR you can truncate that part off (like exampledate_2)gives: