将纪元时间转换为 hadoop/hive 中的 PST 时区
Converting epoch time to PST zone in hadoop/hive
我想将纪元时间转换为 pst 时区。
例如:1482440069 当我转换为 PST 时,我应该得到 2016-12-22
现在,当我尝试这个时,我得到了正确的答案
SELECT from_utc_timestamp('1970-01-01 07:00:00', 'PST');
此外,当我尝试这个时,我得到了正确的值
select from_unixtime(cast(1482440069 as bigint), 'yyyy-MM-dd')
o/p : 2016-12-22
但是,当我尝试这个查询时,我得到 NULL 响应
select from_utc_timestamp(from_unixtime(cast(1482440069 as bigint), 'yyyy-MM-dd'),'PST') -- Gives NULL response
你可以试试:
SELECT from_utc_timestamp(cast(from_unixtime('1970-01-01 07:00:00', 'yyyy-MM-dd HH:mm:ss') as bigint) + (time_zone value like -5 or -6 * 3600));
使用yyyy-MM-dd HH:mm:ss
代替yyyy-MM-dd
hive> select from_utc_timestamp(from_unixtime(cast(1482440069 as bigint), 'yyyy-MM-dd HH:mm:ss'),'PST');
OK
2016-12-22 04:54:29
我想将纪元时间转换为 pst 时区。 例如:1482440069 当我转换为 PST 时,我应该得到 2016-12-22
现在,当我尝试这个时,我得到了正确的答案
SELECT from_utc_timestamp('1970-01-01 07:00:00', 'PST');
此外,当我尝试这个时,我得到了正确的值
select from_unixtime(cast(1482440069 as bigint), 'yyyy-MM-dd')
o/p : 2016-12-22
但是,当我尝试这个查询时,我得到 NULL 响应
select from_utc_timestamp(from_unixtime(cast(1482440069 as bigint), 'yyyy-MM-dd'),'PST') -- Gives NULL response
你可以试试:
SELECT from_utc_timestamp(cast(from_unixtime('1970-01-01 07:00:00', 'yyyy-MM-dd HH:mm:ss') as bigint) + (time_zone value like -5 or -6 * 3600));
使用yyyy-MM-dd HH:mm:ss
代替yyyy-MM-dd
hive> select from_utc_timestamp(from_unixtime(cast(1482440069 as bigint), 'yyyy-MM-dd HH:mm:ss'),'PST');
OK
2016-12-22 04:54:29