select from_unixtime( cast(1597651229344/1000
asint),'
yyyy-mm-dd hh:mm:ss
')
使用函式:str_to_date(str, format)
使用示例:select * from h_hotelcontext where now() between str_to_date(start_time,'%y-%m-%d %h:%i:%s') and str_to_date(end_time,'%y-%m-%d %h:%i:%s');
使用注意點:format的格式為%y-%m-%d %h:%i:%s ,中間的分隔符也需要跟你傳入的字串格式對上
沒用過類似的轉化函式,想去找來著,但是突然發現就按比較字串的邏輯去比較也是可以的
select date_format(now(),'%y%m%d
') --
2020-08-31 17:46:17 轉化為 20200831
select date_format(now(),'yyyymmdd
') --
2020-08-31 17:46:17 轉化為 20200831
unix_timestamp:日期轉時間戳函式
用法:unix_timestamp(string date)
返回值: bigint
說明: 轉換格式為「yyyy-mm-dd hh:mm:ss「的日期到unix時間戳。如果轉化失敗,則返回0。
select unix_timestamp('2018-09-05 12:01:03')
from
dw.ceshi_data;
結果如下:
1536120063
from_unixtime:時間戳轉日期函式
用法:from_unixtime(bigint unixtime[, stringformat])
返回值: string
說明: 轉化時間戳到當前時區的時間格式
select from_unixtime(1423306743,'yyyymmdd')
from
dw.ceshi_data;
結果如下:
20150207
selectunix_timestamp()
from
dw.ceshi_data;
結果如下:
1536126324
hive 中時間戳與時間字串的相互轉換
時間戳是資料庫常用的存放日期的形式之一,表示從 utc 時間 1970 01 01 00 00 00 開始到現在的秒數,與常規時間格式如 2018 01 01 00 00 00 可以相互轉換,方法如下。一 unix timestamp 函式用法 1 unix timestamp 返回當前時間戳。另外...
Python 時間戳 字串 時間 轉換
平時對於時間的處理經常使用python的time和datetime模組,但是用來多次還是對其中的時間戳,字串和時間轉換應用的不太熟練,時間長了不使用就理不清楚,為此整理成文。時間戳,時間,字串之間的關係整理如下圖 時間戳 time.time 返回當前時間戳 seconds time.time tim...
python 時間戳 時間字串轉換
使用time和datetime包進行轉換。環境python2.7.13。gmt 格林威治時間,bjt 北京時間。時間戳轉為時間字串 coding utf 8 時間戳 gmt 轉化為字串 bjt import time import datetime timestamp 1522165684 時間戳是...