hive日期函數(shù)有哪些

這篇文章將為大家詳細(xì)講解有關(guān)hive日期函數(shù)有哪些,小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。

創(chuàng)新互聯(lián)專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)、金東網(wǎng)絡(luò)推廣、成都小程序開發(fā)、金東網(wǎng)絡(luò)營(yíng)銷、金東企業(yè)策劃、金東品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運(yùn)營(yíng)等,從售前售中售后,我們都將竭誠(chéng)為您服務(wù),您的肯定,是我們最大的嘉獎(jiǎng);創(chuàng)新互聯(lián)為所有大學(xué)生創(chuàng)業(yè)者提供金東建站搭建服務(wù),24小時(shí)服務(wù)熱線:13518219792,官方網(wǎng)址:www.muchs.cn

1.日期函數(shù) to_date(string expr)

返回類型:string

描述:返回時(shí)間字符串日期部分

to_date(expr) - Extracts the date part of the date or datetime expression expr

實(shí)例:

hive> select to_date('2014-09-16 15:50:08.119') from default.dual;

2014-09-16


2.年份函數(shù) year(string expr)

返回類型:int

描述:返回時(shí)間字符串年份數(shù)字

year(date) - Returns the year of date

實(shí)例:

hive> select year('2014-09-16 15:50:08.119') from default.dual;

2014


3.月份函數(shù) month(string expr)

返回類型:int

描述:返回時(shí)間字符串月份數(shù)字

month(date) - Returns the month of date

實(shí)例:

hive> select month('2014-09-16 15:50:08.119') from default.dual;

09


4.天函數(shù) day(string expr)

返回類型:int

描述:返回時(shí)間字符串的天

day(date) - Returns the date of the month of date

實(shí)例:

hive> select day('2014-09-16 15:50:08.119') from default.dual;

16


5.小時(shí)函數(shù) hour(string expr)

返回類型:int

描述:返回時(shí)間字符串小時(shí)數(shù)字

hour(date) - Returns the hour of date

實(shí)例:

hive> select hour('2014-09-16 15:50:08.119') from default.dual;

15


6.分鐘函數(shù) hour(string expr)

返回類型:int

描述:返回時(shí)間字符串分鐘數(shù)字

minute(date) - Returns the minute of date

實(shí)例:

hive> select minute('2014-09-16 15:50:08.119') from default.dual;

50

7.秒函數(shù) second(string expr)

返回類型:int

描述:返回時(shí)間字符串分鐘數(shù)字

second(date) - Returns the second of date

實(shí)例:

hive> select second('2014-09-16 15:50:08.119') from default.dual;

08

8.日期增加函數(shù) date_add(start_date, num_days)

返回類型:string

描述:返回增加num_days 天數(shù)的日期(負(fù)數(shù)則為減少)

date_add(start_date, num_days) - Returns the date that is num_days after start_date.

實(shí)例:

hive>select date_add('2014-09-16 15:50:08.119',10) from default.dual;

2014-09-26

hive>select date_add('2014-09-16 15:50:08.119',-10) from default.dual;

2014-09-06

9.日期減少函數(shù) date_sub(start_date, num_days)

返回類型:string

描述:返回num_days 天數(shù)之前的日期(負(fù)數(shù)則為增加)

date_sub(start_date, num_days) - Returns the date that is num_days before start_date.

實(shí)例:

hive>select date_sub('2014-09-16 15:50:08.119',10) from default.dual;

2014-09-06

hive>select date_sub('2014-09-16 15:50:08.119',-10) from default.dual;

2014-09-26

10.周期函數(shù) weekofyear(start_date, num_days)

返回類型:int

描述:返回當(dāng)前日期位于本年的周期 一周一個(gè)周期

weekofyear(date) - Returns the week of the year of the given date. A week is considered to start on a Monday and week 1 is the first week with >3 days.

實(shí)例:

hive>select weekofyear('2014-09-16 15:50:08.119') from default.dual;

38

11.日期比較函數(shù) weekofyear(start_date, num_days)

返回類型:string

描述:返回2個(gè)時(shí)間的日期差

datediff(date1, date2) - Returns the number of days between date1 and date2

date1-date2

實(shí)例:

hive>select datediff('2014-09-16 15:50:08.119','2014-09-15') from default.dual;

關(guān)于“hive日期函數(shù)有哪些”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,使各位可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),請(qǐng)把它分享出去讓更多的人看到。

當(dāng)前名稱:hive日期函數(shù)有哪些
文章位置:http://www.muchs.cn/article28/ghgdjp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供動(dòng)態(tài)網(wǎng)站、網(wǎng)站營(yíng)銷電子商務(wù)、網(wǎng)站設(shè)計(jì)公司、靜態(tài)網(wǎng)站、營(yíng)銷型網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)