Reputation: 37
MYSQL 5.1
I need to create a query that gives my result table three columns, match_date, match_start and match_duration
I need the match_duration column which takes match_start and match_end and displays how long each game has been on for in 00:00 hours format. So for example if it were 5hrs:30 mins it would be displayed 5:30 hours.
This is what I have so far and not sure where I'm going wrong:
SELECT match_date, match_start, DateDiff(hhmm, match_start, match_end) AS Duration
FROM MatchInfo;
Thanks
Upvotes: 0
Views: 3425
Reputation: 34367
Try below:
TIME_FORMAT(TIMEDIFF(match_end, match_start), '%H:%i')
i.e.
SELECT match_date, match_start,
TIME_FORMAT(TIMEDIFF(match_end, match_start), '%H:%i') AS DURATION
FROM MatchInfo;
Upvotes: 4