hive 时间函数

hive 时间函数

20190910


  • 时间截断函数 trunc(string date, string format)返回string
select trunc("2016-06-26","MM") --得到:2016-06-01
select trunc("2016-06-26","YY") --得到:2016-01-01

【注意】 format所支持的格式为MONTH/MON/MM, YEAR/YYYY/YY【大写】

  • timestampdate函数to_date(string timestamp) 返回string
select to_date("1970-01-01 00:00:00") --得到:1970-01-01
  • 时间格式转换date_format(string date, string format)返回string
 select date_format('2015-04-08', 'y') --得到:2015
 select date_format('2015-04-08', 'y-mm') --得到:2015-04
 select date_format('2015-04-08', 'yy-mm') --得到:15-04

【注意】 format所支持的格式为【大写或小写】
【注意】 hive版本是否支持

上面都是参考:Hive2.0函数大全(中文版)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值