0

我在存储纪元时间的表中有一个列。

我想将其转换为人类可读的日期时间戳,时区为 IST。我正在使用以下查询,但转换不正确,它显示的是上次 05:30。

presto:default> select to_char(date_trunc('hour',
     from_unixtime((CAST(substr(startdatetime,1,10) AS double )))),
     'dd-mm-yyyy hh24'),startdatetime FROM rocmetricsolr limit 10;


     _col0     | startdatetime 
---------------+---------------
 NULL          | NULL          
 21-05-2018 23 | 1526905879116 
 21-05-2018 23 | 1526905879116 
 21-05-2018 23 | 1526905874892 
 NULL          | NULL          
 21-05-2018 23 | 1526905876216 
 21-05-2018 23 | 1526905876216 
 21-05-2018 23 | 1526905873640 
 21-05-2018 23 | 1526905873640 
 21-05-2018 23 | 1526905903110
4

1 回答 1

0

假设您有一个表rocmetricsolr,其类型为列startdatetimevarchar其中前 10 位数字表示纪元时间戳:

SELECT from_unixtime(CAST(substr(startdatetime,1,10) AS bigint)) AT TIME ZONE 'America/Los_Angeles'

注意:请根据https://en.wikipedia.org/wiki/List_of_tz_database_time_zones更改时区名称

于 2018-06-14T13:40:25.050 回答