Is there a native Presto function that provides support to extract the timestamp from a timestamp with time zone?
Taking something like this
SELECT PARSE_DATETIME('2022-03-13+02:00:99 UTC', 'yyyy-MM-dd+HH:mm:99 ZZZ') AT TIME ZONE 'UTC' AS utc_time
Which returns a value of:
2022-03-13+02:00:99 UTC
To:
2022-03-13+02:00:99
I couldn’t find information in the docs for this kind of support. It seems as though my only option is to convert this as a varchar, remove the ‘ UTC’ characters, and then re-convert this into a timestamp if I want to remove the time zone suffix from the timestamp with time zone
Advertisement
Answer
You can just cast to timestamp:
SELECT cast(PARSE_DATETIME('2022-03-13+02:00:99 UTC', 'yyyy-MM-dd+HH:mm:99 ZZZ') as timestamp) utc_time
Output:
utc_time |
---|
2022-03-13 02:00:00.000 |