thefollower Posted September 24, 2008 Share Posted September 24, 2008 Im kinda confused here as to how to get this working, im trying to get my script to show the average time of all tasks done but it gives a value of like 184.0000000000 which is meaningless to me thus i don't know what that is telling me if its seconds/minutes/days etc :S? This is what i got: <?php $GET = mysql_query("SELECT UserID, COUNT(TaskID) AS Total,AVG(timediff(CompletedOn,StartedOn)) AS AverageTime FROM usertasktable WHERE Complete='2' GROUP BY UserID ORDER BY Total DESC,AverageTime DESC LIMIT 20") Or die(mysql_error()); While($row = mysql_fetch_assoc($GET)){ $UserID = $row['UserID']; $Get2 = mysql_query("SELECT Username FROM userregistration WHERE UserID='$UserID'") Or die(mysql_error()); $row2 = mysql_fetch_assoc($Get2); $Username = $row2['Username']; $Total = $row['Total']; $Time = $row['AverageTime']; echo 'Name '.$Username .'['.$UserID.']'; echo 'Total Complete '.$Total; echo 'Average Time : '.$Time; } ?> Its the average time that im having difficulties with here... hope you can help me out. Link to comment https://forums.phpfreaks.com/topic/125671-confused-with-script-here/ Share on other sites More sharing options...
jonsjava Posted September 24, 2008 Share Posted September 24, 2008 um.....pancakes on doghouse? There is no way for me to tell you for certain what unit that is measuring in. We would need to see the script that placed the data in the table. Link to comment https://forums.phpfreaks.com/topic/125671-confused-with-script-here/#findComment-649770 Share on other sites More sharing options...
thefollower Posted September 24, 2008 Author Share Posted September 24, 2008 Oops sos, Well the fields are time stamps like this: 2008-09-22 22:00:00 If that is what you meant? Link to comment https://forums.phpfreaks.com/topic/125671-confused-with-script-here/#findComment-649823 Share on other sites More sharing options...
monkeytooth Posted September 24, 2008 Share Posted September 24, 2008 The part thats generating this number.. Whats making this number "184.0000000000" if we know whats generating that number and how, we can then better help with an output thats a little more taliored to your needs Link to comment https://forums.phpfreaks.com/topic/125671-confused-with-script-here/#findComment-649899 Share on other sites More sharing options...
thefollower Posted September 24, 2008 Author Share Posted September 24, 2008 The part thats generating this number.. Whats making this number "184.0000000000" if we know whats generating that number and how, we can then better help with an output thats a little more taliored to your needs Thank you for your replies guys, This is what is generating the number (from the mysql) AVG(timediff(CompletedOn,StartedOn)) AS AverageTime Imagine rows of timestamps of started and stops for different times.. it works out the time difference of the started and completed then works out the Average time of all them start and stop time differences.. which produced: 184.0000000000 My exact rows that it is using is: Completed On Started On 2008-09-24 00:25:17 | 2008-09-19 15:16:03 2008-09-19 15:15:50 | 2008-09-14 01:58:32 2008-09-14 00:46:42 | 2008-09-14 00:43:03 Link to comment https://forums.phpfreaks.com/topic/125671-confused-with-script-here/#findComment-649918 Share on other sites More sharing options...
thefollower Posted September 24, 2008 Author Share Posted September 24, 2008 bumping. Link to comment https://forums.phpfreaks.com/topic/125671-confused-with-script-here/#findComment-649956 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.