How do I make a substraction of two columns of type Time in MySQL and get the result in minutes? Thanks!
Asked
Active
Viewed 55 times
1 Answers
1
One method is to convert to seconds and then back to minutes:
floor(time_to_sec(time1) - time_to_sec(time2) / 60) as MinutesDiff

Gordon Linoff
- 1,242,037
- 58
- 646
- 786
-
1You forget round brackets [demo](http://sqlfiddle.com/#!9/9eecb7d/36462/0) `floor((time_to_sec(time1) - time_to_sec(time2)) / 60)` or using integer division `(time_to_sec(time1) - time_to_sec(time2)) DIV 60 AS MinuteDiff` – Lukasz Szozda Dec 20 '15 at 18:13