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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Add up times.

Status
Not open for further replies.

Raid5

IS-IT--Management
Oct 16, 2002
36
US
How would I add up calculated times.

EX. 1:45
3:30

I get the number 2 in my report I am expecting 5:15.
Can Crystal even add up times?
 
Is this what it looks like in the database, just a time field with no date?

And how do you want to display 23:45 + 22:45? Should it have an additional days column, or show 56:30?

You can accumulate the times using a formula in the details (or wherever) using a formula such as:

whileprintingrecords;
numbervar Hours := Hours+val(left("01:45",instr("01:45",":")-1));
numbervar Minutes := Minutes + val( mid("01:45",instr("01:45",":")+1,2));

If this is within a group, then first set the values to 0 in the group header:

whileprintingrecords;
numbervar Hours := 0;
numbervar Minutes := 0;

Then in the Group Header (or report footer if there isn't a group) use the following in a formula to display it:

whileprintingrecords;
numbervar Hours;
numbervar Minutes;
Minutes := remainder(Minutes,60);
Hours := Hours + truncate(remainder(Minutes,60));
totext(Hours,0,"")+":"+totext(minutes,0,"")

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top