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
you can use mysql funcion timestampdiff like below
TIMESTAMPDIFF(HOUR, '2018-06-01 00:00:00', '2018-06-01 12:00:00')
for getting Diffrence in Hour :
Hour(TIMEDIFF(date1,date2)) as Hour1
for getting Diffrence in Minute :
Minute(TIMEDIFF(date1,date2)) as Minute1
for getting Diffrence in Second :
Second(TIMEDIFF(date1,date2)) as Second1
HOUR(TIMEDIFF(endDate, startDate))
might work—if I'm reading the docs correctly.
select hour(timediff('2017-01-01 00:00:00', '2017-01-01 00:01:00'));
return 1
select hour(timediff('2017-01-01 00:01:00', '2017-01-01 00:00:00'));
return 1
select time_to_sec(timediff('2017-01-01 00:00:00', '2017-01-01 00:00:05'));
return -5
select time_to_sec(timediff('2017-01-01 00:00:00', '2017-01-01 00:00:05'))/60 as 'minutes' ;
return -0.0833
if you have the seconds you can convert it as you want or what and hours(..) will not use it when i compare because it's always postive value