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;
谢谢
最佳答案
尝试以下:
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;
关于mysql - MYSQL 5.1 中的 DateDiff 函数。需要数小时+分钟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13632927/