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

如题所述

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
温馨提示:答案为网友推荐,仅供参考
第1个回答  推荐于2018-03-05
时间为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')本回答被网友采纳
第2个回答  2017-08-17
from_unixtime(unix_timestamp(COL,'yyyyMMddHHmmss'), 'yyyy-MM-dd HH:mm:ss')
相似回答