Print Page | Close Window

Sum & Average of times

Printed From: Crystal Reports Book
Category: General Information
Forum Name: Talk with the Author
Forum Discription: Ask Brian questions about his books and give him your comments. Like the book? Hate the book? Have suggestions? Let me know!
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=20904
Printed Date: 25 Apr 2024 at 3:01pm


Topic: Sum & Average of times
Posted By: hayfsh
Subject: Sum & Average of times
Date Posted: 22 Jul 2014 at 10:45pm
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



Print Page | Close Window