hive中时间日期函数的使用

本文提供一个hive中时间函数表

函数作用示例输出
to_date日期时间转日期函数select to_date(‘2015-04-02 13:34:12’);2015-04-02
from_unixtime转化unix时间戳到当前时区的时间格式select from_unixtime(1323308943,’yyyyMMdd’);20111208
unix_timestamp获取当前unix时间戳select unix_timestamp();1430816254
unix_timestamp日期转UNIX时间戳select unix_timestamp(‘2015-04-30 13:51:20’);1430373080
year返回日期中的年select year(‘2015-04-02 11:32:12’);2015
month返回日期中的月份select month(‘2015-12-02 11:32:12’);12
day返回日期中的天select day(‘2015-04-13 11:32:12’);13
hour返回日期中的小时select hour(‘2015-04-13 11:32:12’);11
minute返回日期中的分钟select minute(‘2015-04-13 11:32:12’);32
second返回日期中的秒select second(‘2015-04-13 11:32:56’);56
weekofyear返回日期在当前周数select weekofyear(‘2015-05-05 12:11:1’);19
datediff返回开始日期减去结束日期的天数select datediff(‘2015-04-09’,’2015-04-01’);8
date_sub返回日期前n天的日期elect date_sub(‘2015-04-09’,4);2015-04-05
date_add返回日期后n天的日期select date_add(‘2015-04-09’,4);2015-04-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值