I\'m Trying to get the timediff from my table and convert it to hours (it\'s for an hourly billed service)
SELECT TIME_TO_SEC(TIMEDIFF(endDate,startDa
TIMESTAMPDIFF(HOUR, startDate, endDate)
is the best way to do it, because it works with big time intervals, like
TIMESTAMPDIFF(HOUR, "2012-01-01 00:00:00", "2050-01-01 00:00:00")
Result: 333120
while
HOUR(TIMEDIFF("2050-01-01 00:00:00", "2012-01-01 00:00:00"))
Result: 838
fails.
As we see in the example above, it surprisingly even works beyond the timestamp limitation in year 2038.
The maximum hours which are returned by HOUR(TIMEDIFF(dateEnd, dateStart)) is 838, because TIMEDIFF is limited to the range allowed for TIME values.