How can I convert a timestamp field that includes day and time to local time in Prestosql? The fields look like
Region ID | Start Time utc | End Time utc
abc 2019-04-26 20:00:00.000 2019-04-26 23:00:00.000
cdx 2019-02-27 23:30:00.000 2019-02-28 01:00:00.000
I have the Region IDS so if I need to or if it makes it easier I can enter in the query the ids of the timezone I would need for that row.
I want to just return the local start and end time for that timezone.
the query is
SELECT table1.*
FROM table1
WHERE table1.day = date '2019-04-03' AND
NOT EXISTS (SELECT 1
FROM table2
WHERE table1.id = table2.id AND
table1.timestamp >= table2.start_time AND
table1.timestamp <= table2.end_time
)
Where table 2 is the start and end time in which I want to convert to local times...
where the utc time is in the not exists clause for start and end time, how would I change that to local times ? not all the times would be the same timzone in america? There is a region Id field that I can use to link that region id to a timezone can I use that?
From presto's documentation
SELECT timestamp '2012-10-31 01:00 UTC' AT TIME ZONE 'America/Los_Angeles';
2012-10-30 18:00:00.000 America/Los_Angeles
As the current timestamp you have is already in UTC, you can add the locality for the timestamp and get desired results.
Hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With