hive中日期與時間戳轉換

2021-07-25 08:49:16 字數 921 閱讀 6280

從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

Hive中日期與時間戳轉換

1.時間戳轉成日期 select distinct from unixtime 1441565203,yyyy mm dd hh mm ss from test date 2.日期轉成時間戳 select distinct unix timestamp 20111207 13 01 03 from ...

Hive中日期與時間戳的轉換

什麼是時間戳?時間戳是指 格林尼治時間 1970年01月01日00時00分00秒 北京時間1970年01月01日時00分00秒 起至現在的總秒數。注意 不管你在地球上的任何地方,這一時刻的時間戳是相同的。但是!同乙個時間戳在不同的時區會表示不同的時間。比如在集群上通過hive函式轉換的是北京時間,但...

python 中 日期,時間戳的轉換

一,日期轉換成為時間戳 1,首先需要引入模組,time datetime import time datetime2,把輸入的字元轉換成為陣列 python time strptime 函式根據指定的格式把乙個時間字串解析為時間元組。time.strptime string format tsl 2...