0

How do I make a substraction of two columns of type Time in MySQL and get the result in minutes? Thanks!

Sredny M Casanova
  • 4,735
  • 21
  • 70
  • 115

1 Answers1

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
  • 1
    You 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