hive时间戳格式化

来源:互联网 发布:ubuntu 更新grub 编辑:程序博客网 时间:2024/06/05 19:17

1、from_unixtime()函数:

语法:from_unixtime(t1,'yyyy-MM-dd HH:mm:ss')

其中t1是10位的时间戳值,即1970-1-1至今的秒,而13位的所谓毫秒的是不可以的。

对于13位时间戳,需要截取,然后转换成bigint类型,因为from_unixtime类第一个参数只接受bigint类型。例如:

select from_unixtime(cast(substring(tistmp,1,10) as bigint),'yyyy-MM-dd HH')  tim ,count(*) cn from ttengine_hour_data where ...


0 0