0

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

ypercubeᵀᴹ
  • 113,259
  • 19
  • 174
  • 235
user1745447
  • 37
  • 3
  • 9

1 Answers1

4

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;
Yogendra Singh
  • 33,927
  • 6
  • 63
  • 73