[英]Prestosql converting UTC timestamp to local?
How can I convert a timestamp field that includes day and time to local time in Prestosql?如何将包含日期和时间的时间戳字段转换为 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.我有区域 IDS,所以如果我需要或者如果它更容易,我可以在查询中输入该行所需的时区 ID。
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...其中表 2 是我要转换为当地时间的开始和结束时间......
where the utc time is in the not exists clause for start and end time, how would I change that to local times? utc 时间在开始和结束时间的不存在子句中,我如何将其更改为当地时间? 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?
我可以使用区域 ID 字段将该区域 ID 链接到时区,我可以使用它吗?
From presto's documentation来自presto 的文档
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.由于您拥有的当前时间戳已经采用 UTC,因此您可以为时间戳添加位置并获得所需的结果。
Hope this helps希望这可以帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.