2014-01-16 190 views
2

我在我的數據庫中的以下行:從時間戳SQL選擇日期

'1', '1', '1', 'Hello world', 'Hello', '2014-01-14 17:33:34' 

現在我希望選擇該行,並從該時間戳只得到日期:

我已經試過如下:

SELECT title, FROM_UNIXTIME(timestamp,'%Y %D %M') AS MYDATE FROM Team_Note TN WHERE id = 1 

我也曾嘗試:

SELECT title, DATE_FORMAT(FROM_UNIXTIME(`timestamp`), '%e %b %Y') AS MYDATE FROM Team_Note TN WHERE id = 1 

然而,這些只是返回一個空結果(或好我得到的Hello一部分,但指明MyDate是空的)

+0

什麼是時間戳列的列格式? – Sebas

回答

10

你試試這個?

SELECT title, date(timestamp) AS MYDATE 
FROM Team_Note TN 
WHERE id = 1 
+0

...感謝隊友如此愚蠢:P –