I have this query:
SELECT sum(TIMEDIFF(`time_out`, `time_in`)) as `total` FROM `user_log` WHERE `uid` = '1' AND `time_out` <> '0000-00-00 00:00:00'
Then I calculate the seconds to hours:
$total_difference = (($difference->total) / 60 / 60);
But this is showing me 22,352125 hours, which is impossible...
I've been testing and I have 2 records showing up if I don't use SUM:
SELECT TIMEDIFF(`time_out`, `time_in`) as `total` FROM `user_log` WHERE `uid` = '1' AND `time_out` <> '0000-00-00 00:00:00'
- 08:00:02
- 00:00:11
This result is far below the 22 hours I get when I use SUM in my query. Any help? I don't know what I'm doing wrong.
Thanks!
SUM(TIME_TO_SEC(TIMEDIFF(time_out,time_in)))