01-24-2023 08:33 PM
I have a field stored as a string in the format "12/30/2022 10:30:00 AM"
What is the easiest way to convert the string into a timestamp, with the timezone of my choosing?
01-24-2023 10:42 PM
01-29-2023 11:06 PM
I don't seem to be getting the same result... note no timezone info in my results;
Is there a config setting I'm missing or something?
01-30-2023 04:57 PM
Just to answer my own question, in case anyone else googles for this...
FirstIy, don't know why timezone isn't displaying in my query results using a SQL Warehouse, but it works ok using a compute cluster, so I'm guessing it is a display issue rather than a data issue.
Secondly, from what I can tell, using the TO_TIMESTAMP function will apply the timezone for your session (which might not be the timezone you want). I didn't realise this could be solved pretty easily by simply pasting your timezone to the end of the date string, like this;
TO_TIMESTAMP(MyDateTimeString || ' Timezone', 'M/d/y h:m:s a z)
For example;
TO_TIMESTAMP(MyDateTimeString || ' America/Los_Angeles', 'M/d/y h:m:s a z)
02-04-2023 06:30 AM
Use to_utc_timestamp(expr,timezone)
01-25-2023 04:07 AM
02-03-2023 03:48 AM
use from_utc_timestamp(to_timestam("<string>", <format>),<timezone>)
Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections.
Click here to register and join today!
Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.