Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time Difference and Running Total 1

Status
Not open for further replies.

wilsons935

IS-IT--Management
Jul 12, 2004
9
GB
I have two fields showing start and end time (hh:mm:ss). I need to calculate the difference bewteen the times per row and then start a running total adding up the time and showing it as hh:mm:ss for each user

Example data:

User1 09:10:05 10:10:05 time difference
User1 12:01:01 12:02:01 time difference
sub total time

User2 10:01:01 11:01:01 time difference
User2 11:00:00 13:00:00 time difference
sub total time

I am using CR8.5 and have used the following formula to calculate the time difference

ctime({UserStats.EndTime} - {UserStats.StartTime})

This gives me a difference in hh:m:ss but I cannot work out how to do the running total so that it adds up the time correctly.

Any help appreciated. If I have left any relevant information out my apologies.

Al Patch

 
I think you could use one formula to display the difference per record, and a second formula with results in seconds to accumulate in your running total. To get seconds, you could use a formula like {@seconds}:

datediff("s",{table.starttime},{table.datetime})

Use the running total editor to accumulate {@seconds} in a running total {#seconds}, resetting on change of group (user ID), and then plug it into Synapsevampire's FAQ formula for converting seconds to hh:mm:ss format:

numberVar dur := {#seconds};
numberVar hrs;
numberVar min;
numberVar sec;
stringVar hhmmss;

hrs := Truncate(Truncate(dur/60)/60);
min := Remainder(Truncate(dur/60),60);
sec := Remainder(dur,60);

hhmmss := totext(hrs, "0") + ":" + totext(min, "00") + ":" + totext(sec, "00");

hhmmss

The running total needs to be in the group footer.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top