0

In my database I have 2 column who has DATETIME as variable (starts & ends): db What I'm trying to do it's to SUM the hours between starts and ends.

I tried SELECT DATEDIFF(starts, ends) AS myTotal FROM assenze <- (assenze is the table i'm currently working with)

But this is the output

I know for sure it's not correct, like the first one should be 8H

Can someone help me pls?

aim0d
  • 129
  • 7
  • DateDiff() is the wrong function. If you [read the docs](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_datediff) it explains that function returns the number of *days* between two dates, not time. The function you want is [TimestampDiff()](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_timestampdiff) – SOS Apr 01 '22 at 06:47
  • 1
    Oh okay, thanks. Didnt find anything about that. I'm new to this world, didnt know about Docs (it did works) – aim0d Apr 01 '22 at 07:04

0 Answers0