hive 中怎么unix时间戳转化为"yyyy-mm-dd hh:mm:ss

2025-05-16 21:24:34
推荐回答(3个)
回答(1):

1.日期函数UNIX时间戳转日期函数: from_unixtime语法:from_unixtime(bigint unixtime[, stringformat])
返回值: string
说明: 转化UNIX时间戳(从1970-01-0100:00:00 UTC到指定时间的秒数)到当前时区的时间格式
举例:
hive> select from_unixtime(1323308943,'yyyyMMdd') from dual;
20111208
2.获取当前UNIX时间戳函数: unix_timestamp语法: unix_timestamp()
返回值: bigint
说明: 获得当前时区的UNIX

回答(2):

时间为00:00:00:

select from_unixtime(unix_timestamp(),'yyyy-MM-dd 00:00:00')
时间为当前时间:

select from_unixtime(unix_timestamp(),'yyyy-MM-dd HH:mm:ss')

回答(3):

from_unixtime(unix_timestamp(COL,'yyyyMMddHHmmss'), 'yyyy-MM-dd HH:mm:ss')