hive时间戳格式化

    xiaoxiao2021-03-25  133

    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 ...

    转载请注明原文地址: https://ju.6miu.com/read-10545.html

    最新回复(0)