HIVE 日期函数
时间戳转日期:from_unixtime
转化时间戳到时间格式
hive (default)> select from_unixtime(1563983370,‘yyyy-MM-dd’);
2019-07-24
获取当前时间戳:unix_timestamp
hive (default)> select unix_timestamp();
1563983370
日期转时间戳:unix_timestamp
hive (default)> select unix_timestamp(‘2019-07-24 13:01:03’);
1563944463
指定格式日期转时间戳:unix_timestamp
hive (default)> select unix_timestamp(‘2019-07-07 23:20:42’,‘yyyy-MM-dd HH:mm:ss’);
1562512842
判断日期是当年第几周:weekofyear
hive (default)> select weekofyear(‘2019-01-27 10:03:01’);
4
判断两个日期相差几天: datediff
hive (default)> select datediff(‘2019-07-08’,‘2019-07-05’);
3
日期增加: date_add
当前日期n天后的日期