2016-05-31 306 views

回答

0

我工作圍繞這通過使用concat(substr(your_date_column,1,13), ':00')

如果日期列有一個保留關鍵字如timestamp在我的情況下,這個工程 - CONCAT(SUBSTR(`timestamp`,1,13),「: 00' )

1

要日期轉換爲指定字符串格式,你必須使用的蜂巢

from_unixtime(bigint unixtime[, string format])from_unixtime()功能的秒數從Unix紀元(1970-01-01 00:00:00 UTC)轉換爲表示當前系統時區中該時刻的時間戳的字符串。

樣品的輸入和輸出可以從下面的圖像中可以看出: enter image description here

最後的查詢是

select from_unixtime(unix_timestamp(),'yyyy-MM-dd HH') as my_date from table1; 

其中表1存在於我的蜂房數據庫中的表名。

我希望這可以幫助您實現date_format(your_date_column, '%Y-%m-%d %H') !!!

+0

非常感謝您Farooque – usert4jju7

相關問題