常用日期函数
unix_timestamp:返回当前或指定时间的时间戳
select unix_timestamp();
select unix_timestamp("2020-10-28",'yyyy-MM-dd');
from_unixtime:将时间戳转为日期格式
select from_unixtime(1603843200);
current_date:当前日期
select current_date;
current_timestamp:当前的日期加时间
select current_timestamp;
to_date:抽取日期部分
select to_date('2020-10-28 12:12:12');
year:获取年
select year('2020-10-28 12:12:12');
month:获取月
select month('2020-10-28 12:12:12');
day:获取日
select day('2020-10-28 12:12:12');
hour:获取时
select hour('2020-10-28 12:12:12');
minute:获取分
select minute('2020-10-28 12:12:12');
second:获取秒
select second('2020-10-28 12:12:12');
weekofyear:当前时间是一年中的第几周
select weekofyear('2020-10-28 12:12
本文介绍了Hive中的常用日期和字符串操作函数,包括unix_timestamp、from_unixtime、current_date、current_timestamp、to_date等日期函数,以及year、month、day、hour等时间部分抽取函数。此外,还讲解了round、ceil、floor等取整函数和upper、lower、length、trim等字符串处理函数,以及集合操作如size、map_keys、map_values、array_contains和sort_array。
订阅专栏 解锁全文
2955

被折叠的 条评论
为什么被折叠?



