欢迎投稿

今日深度:

Hive日期函数,

Hive日期函数,



hive日期函数 函数用法 含参方式 用法备注
hive日期函数 函数用法 含参方式 用法备注
date2datekey date格式转换成datekey date2datekey(string date/time)

date2datekey('2017-09-01')

返回:'20170901'

date_add 往后加上days date_add(string startdate, int days)

date_add('2017-12-08',10)

返回: '2017-12-18'

date_sub 往前减少days date_sub (string startdate, int days)

date_add('2012-12-18',10)

返回:'2012-12-08'

datediff 日期差函数 datediff(string enddate, string begindate)

datediff('2017-09-03','2017-09-01')

返回:2

datekey2date date key格式转换成date datekey2date(string datekey)

datekey2date('20170901')

返回:'2017-09-01'

day 获取日期函数 day(string date)

('2011-12-08 10:03:01')

返回:'08'

from_unixtime 日期函数UNIX时间戳转日期函数 from_unixtime(bigint unixtime,[ string format])

from_unixtime(1323308943,'yyyyMMdd')

返回:'20111208'

hour 获取小时函数 hour(string date)

('2011-12-08 10:03:01')

返回:'10'

minute 获取分钟函数 minute(string date)

('2011-12-08 10:03:01')

返回:'03'

month 获取月函数 month(string date)

('2011-12-08 10:03:01')

返回:'12'

second 获取秒函数 second(string date)

('2011-12-08 10:03:01')

返回:'01'

to_date 转换成日期 to_date('string time')

to_date(’2011-12-08 10:03:01′) 

返回:'2011-12-08'

unix_timestamp 日期转UNIX时间戳函数 unix_timestamp(string format)

unix_timestamp(’2011-12-07 13:01:03′)

返回:1323309615

weekofyear 当前周数 weekofyear(string date)

weekofyear('2011-12-08 10:03:01')

返回:49

year 获取年函数 year(string date)

year('2011-12-08 10:03:01')

返回:'2011'


www.htsjk.Com true http://www.htsjk.com/hive/41649.html NewsArticle Hive日期函数, hive日期函数 函数用法 含参方式 用法备注 hive日期函数 函数用法 含参方式 用法备注 date2datekey date格式转换成datekey date2datekey(string date/time) date2datekey('2017-09-01') 返回:'...
相关文章
    暂无相关文章
评论暂时关闭