2012-11-29 27 views
0

MYSQL 5.1MYSQL 5.1中的DateDiff函數。需要時間+分鐘

我需要創建一個查詢,給我的結果表三列,match_date,match_start和match_duration

我需要match_duration列這需要match_start和match_end和顯示的時間每遊戲已在00:00小時格式。例如,如果是5小時:30分鐘,則會顯示5:30小時。

這是我到目前爲止並不能肯定我要去哪裏錯了:

SELECT match_date, match_start, DateDiff(hhmm, match_start, match_end) AS Duration 
FROM MatchInfo; 

感謝

+1

你使用哪個數據庫系統? Mysql,SQL Server,Oracle,Postgres? –

+0

對不起忘了補充一下,我用的是MYSQL 5.1 – user1745447

回答

4

嘗試以下:

TIME_FORMAT(TIMEDIFF(match_end, match_start), '%H:%i') 

SELECT match_date, match_start, 
      TIME_FORMAT(TIMEDIFF(match_end, match_start), '%H:%i') AS DURATION 
    FROM MatchInfo; 
相關問題