Sum & Average of times

Printed From: Crystal Reports Book — Forum Name: Talk with the Author

Hello

I am looking for some help in creating a formula which will give me the total time spent on calls during a period.

I have used the below formula to calculate the time spent on each call, but I need to sum this total but an struggling to find a solution.

NumberVar TotalSec := DateDiff ("s" ,{work_order.work_started_date_time}, {work_order.work_finished_date_time});
NumberVar Days    := Truncate (TotalSec / 86400);
NumberVar Hours   := Truncate (Remainder ( TotalSec , 86400) / 3600) ;
NumberVar Minutes := Truncate (Remainder ( TotalSec , 3600) / 60) ;
NumberVar Seconds := Remainder (TotalSec , 60) ;

if Days >= 1 and Hours < 24 then Totext ( Days ,    '00' ) + ' Days' +chr(13) + Totext ( Hours ,   '00' ) + ' Hours' + chr(13) + Totext ( Minutes , '00') + ' Mins'
else
if Hours >= 1 and Hours < 24 then Totext ( Hours ,   '00' ) + ' Hours' + chr(13) + Totext ( Minutes , '00') + ' Mins'
else
if Minutes >=0 and Hours < 1 then Totext ( Minutes , '00') + ' Mins';


Further to the above total I will then need to find the average time spent on a call so any help on this also would be appreciated.

Cheers