MYSQL 5.1中的DateDiff函数。需要时数+分钟

时间:2012-11-29 19:09:46

标签: mysql sql select datediff

MYSQL 5.1

我需要创建一个查询,为我的结果表提供三列,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 个答案:

答案 0 :(得分: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;