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
时间为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')
from_unixtime(unix_timestamp(COL,'yyyyMMddHHmmss'), 'yyyy-MM-dd HH:mm:ss')