hive 時間戳 時間 相互轉換

從1970-01-01 00:00:00 UTC到指定時間的秒數。
總結:時間戳到日期時間,日期時間到時間戳,日期時間到日期。


獲取時間戳:select distinct unix_timestamp() from test_date;


時間戳>>>>日期:select distinct  from_unixtime(1441565203,'yyyy/MM/dd HH:mm:ss') from test_date; 
2015/09/07 02:46:43


日期時間>>>>>>時間戳:默認格式爲“yyyy-MM-dd HH:mm:ss“:
select distinct unix_timestamp('2015-09-07 02:46:43') from test_date;
1441565203


指定日期時間>>>>>>時間戳: 
select distinct unix_timestamp('20111207 13:01:03','yyyyMMdd HH:mm:ss') from test_date;     
1323234063
 
//要接受的類型


日期時間>>>>>>日期: 
select distinct to_date('2011-12-08 10:03:01') from test_date;
結果:2011-12-08


日期時間>>>>>>年/月/日/時/分/秒:   year(string date),month(),day(),hour(),minute(),second()。
select distinct year('2011-12-08 10:03:01') from test_date;
2011
select distinct second('2011-12-08 10:03:01') from test_date;
1


原文:https://blog.csdn.net/shuangshaung_/article/details/53611188 
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章