Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

how to calculate Average Time Duration Expand / Collapse
Author
Message
Posted Friday, October 25, 2013 3:30 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, December 15, 2014 8:18 AM
Points: 48, Visits: 275
Hi,

I am counting values from database like

Total Calls Made:0:53:29 , Total Calls Received:0:11:25 , Total Call Duration:1:4:54

Total Calls Made:43 , Total Calls Received:5 , Total Call Duration:1:4:54

here how to calculate Average Time Duration:

Total Time Duration / (Total Calls Made + Total Calls Received)
(1995 +20214) / (43+5 )

How can we calculate the Average time(In hrs:mm:ss)

How can we calculate the Average time.

Thanks
Post #1508615
Posted Friday, October 25, 2013 4:20 PM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Today @ 2:28 PM
Points: 4,043, Visits: 9,191
Your formula seems correct but you don't have number or calls made or received, instead you have duration of them. Check your data and post again.



Luis C.
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1508620
Posted Thursday, December 12, 2013 5:33 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, September 18, 2014 1:46 PM
Points: 106, Visits: 369
To calculate "average duration", convert the duration for each record to milliseconds, then average the number of milliseconds for the group. Once you have that, then add that to a "zero" date and format it as time. In this example, the average milliseconds is the "12345" value:
SELECT CONVERT(VARCHAR(12), DATEADD(MILLISECOND, 12345, 0), 14) AS Duration

Duration
------------
00:00:12:347


Post #1522537
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse