hive 时间戳和日期相互转换函数的使用
文章目录
hive
1.日期转时间戳函数 unix_timestamp2.时间戳转日期函数 from_unixtime
1.日期转时间戳函数 unix_timestamp
#第一种用法 返回当前时间的时间戳
select unix_timestamp();
#第二种用法 返回指定日期的时间戳且日期不符合格式
select unix_timestamp('20220317 12:01:56','yyyy-MM--dd HH:mm:ss');
#第三种用法 返回指定日期的时间戳且日期符合格式
select unix_timestamp('2022-03-17 12:01:56');
2.时间戳转日期函数 from_unixtime
#第一种用法 时间戳转换成默认格式的日期 select from_timeunix(1534523562); #第二种用法 时间戳转换成指定格式的日期 select from_timeunix(1343424546,'yyyyMMdd HH:mm:ss')



