實戰 - Hive 日期時間運算與比較

日期比較:2個時間的比較,返回2個時間相差的天數。

--函數: datediff(string end_date,string start_date); 
select datediff("2017-06-16 15:00:01","2017-06-15 15:01:01");  --輸出: 1
select datediff("2017-06-16 15:00:01","2017-06-18 16:01:01");  --輸出: -2

增加數天。

--函數: date_add(string start_date, int days);
select date_add("2017-06-16 15:00:01",3);   --輸出: 2017-06-19

減去數天。

--函數: date_sub(string start_date, int days);
select date_sub("2017-06-16 15:00:01",3);   --輸出: 2017-06-13
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章