undressbonifacio Posted May 28, 2010 Share Posted May 28, 2010 hello everyone im new here in your community... may i ask how to convert this into hour:minute:second? SELECT *, SUM(timediff(idleend, idlestart)) as totalidle FROM idletime WHERE idlestart BETWEEN '$dfrom' AND '$dto' GROUP BY agentid ORDER BY agentname the totalidle=131.000000 Quote Link to comment Share on other sites More sharing options...
Mchl Posted May 28, 2010 Share Posted May 28, 2010 SELECT *, TIME(SUM(timediff(idleend, idlestart))) as totalidle FROM idletime WHERE idlestart BETWEEN '$dfrom' AND '$dto' GROUP BY agentid ORDER BY agentname Quote Link to comment Share on other sites More sharing options...
undressbonifacio Posted May 31, 2010 Author Share Posted May 31, 2010 how come the 131.000000 become 00:01:31? it must be 00:02:11.. Quote Link to comment Share on other sites More sharing options...
Mchl Posted May 31, 2010 Share Posted May 31, 2010 Nope. It's MySQL's time format. YYYYMMDDHHMMSS.mmmmmmm SELECT TIME(SUM(timediff(NOW(), NOW() - INTERVAL 130 SECOND))),SUM(timediff(NOW(), NOW() - INTERVAL 130 SECOND)) Quote Link to comment Share on other sites More sharing options...
undressbonifacio Posted June 2, 2010 Author Share Posted June 2, 2010 hello Mchl, thank for your idea... this is my version function secToTime($s) { if ($s > 0) { $mins = floor ($s / 60); $secs = $s % 60; $hrs = floor ($mins / 60); $mins = $mins - ($hrs*60); $hrs = sprintf("%02d",$hrs); $mins = sprintf("%02d",$mins); $secs = sprintf("%02d",$secs); return $hrs.':'.$mins.':'.$secs; } } after this query $myquery = "SELECT *, SUM(timediff(idleend, idlestart)) as totalidle FROM idletime WHERE idlestart BETWEEN '$dfrom' AND '$dto' AND idleend!='0000-00-00 00:00:00' GROUP BY agentid ORDER BY agentname"; echo secToTime($row['totalidle']); it will return perfect... thanks again dude.. BTW how to tag this as SOLVED? Quote Link to comment Share on other sites More sharing options...
Mchl Posted June 2, 2010 Share Posted June 2, 2010 Green button at the bottom on the left (above quick reply) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.