行业知识
【Hive-Sql】Hive 处理 13 位时间戳得到年月日时分秒(北京时间)
2026-11-04 08:34:43
来源:互联网转载
【Hive-Sql】Hive 处理 13 位时间戳得到年月日时分秒(北京时间)
- 1)需求
- 2)实���
1)需求
使用 Hive 自带函数 将 13位 时间戳转成年月日时分秒(北京时间),格式样例:‘2023-01-13 12:23:41’
()2)实现
select from_utc_timestamp(1682238448915, 'GMT+8');-- 结果:2023-04-23 16:27:28.915000000,包含毫秒了select from_unixtime(cast(1682238448915 / 1000 as bigint), 'yyyy-MM-dd HH:mm:ss');-- 结果:2023-04-23 08:27:28,差了8小时select from_unixtime(cast(substring(1682238448915, 1, 10) as bigint), 'yyyy-MM-dd HH:mm:ss');-- 结果:2023-04-23 08:27:28,差了8小时select date_format(from_utc_timestamp(1682238448915, 'GMT+8'), 'yyyy-MM-dd HH:mm:ss');// 结果:2023-04-23 16:27:28,就是想要的结果
所以处理办法是:
select date_format(from_utc_timestamp(1682238448915, 'GMT+8'), 'yyyy-MM-dd HH:mm:ss');
()
上一篇:op服务器工具怎么用?
下一篇:ps怎么做滴墨效果?