EchoFool Posted September 11, 2008 Share Posted September 11, 2008 Hey, Im trying to get my script to work out average time of completion over a range of start and end times of tasks but the result using the AVG function gives a number on huge values because im using time stamps so have no idea how to get it in the format of: Days : Houses : Minutes : Seconds How ever at moment i keep getting results like: UserID 4 Total 58 Average 19388391265527 Its the average thats incorrect This is what i have: <?php $GET = mysql_query("SELECT Count(MissionID) AS Total,AVG((CompletedOn-StartedOn)) AS AverageTime,UserID FROM tasktime WHERE Complete='2' GROUP BY UserID ORDER BY Total DESC,AverageTime DESC LIMIT 20") Or die(mysql_error()); While($row = mysql_fetch_assoc($GET)){ Echo 'UserID '.$row['UserID']; Echo '<br>'; Echo 'Total '.$row['Total']; Echo '<br>'; Echo 'Average '.$row['AverageTime']; ?> Any chance can point me in right direction Link to comment https://forums.phpfreaks.com/topic/123758-maths-help/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.