Jump to content

Recommended Posts

I am having difficulties with my MYSQL query. I am trying to work out a average time from a set of rows which each have their own "Start Date" and "End Date".... so im trying to work out the difference between start and end then find the average time taken beween the start and end from all the rows.. this is what i have tried:

 

Example table:

_____Started On__________ Ended On___________UserID_________TaskID

2008-10-26 11:27:24  2008-10-26 11:26:04---------  1--------- ------- 1

2008-10-26 04:12:42 2008-10-26 04:10:36---------  1--------- ------- 2

2008-10-26 01:21:23 2008-10-26 01:17:19---------  1--------- ------- 3

2008-10-25 20:18:19 2008-10-25 20:11:28---------  1--------- ------- 4

 

<?php
$GET = mysql_query("SELECT UserID, COUNT(TaskID) AS Total, AVG(timediff(CompletedOn,StartedOn)) AS AverageTime FROM usertable WHERE Complete='2' GROUP BY UserID ORDER BY Total DESC,AverageTime DESC LIMIT 20")
Or die(mysql_error());
?>

 

 

Currently though the average time response looks like this:

 

Average Time : 73064.4634146341

 

But i wanted it to reply in days / hours / minutes / seconds. Please help :)

Link to comment
https://forums.phpfreaks.com/topic/132782-solved-average-time-help/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.