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

Add time fields?

Status
Not open for further replies.

huckfinn19

Programmer
May 16, 2003
90
CA
Hi, I've got some time fields like those following :

00:11:18
00:20:30
01:10:02
...
I'd like to make a total so that the result would have the same format (i.e. = 01:41:50). Is there any easy way to do that ?

Thanks

Sim
 
Can't think of a real simple way, but this should do it:

One method might be to convert the fields to their seconds equivalent, and then just use the standard seconds to time format (I have a FAQ on this in one of the Crystal forums).

Here's another thought too:

Details formula to add each element up of a time type:
whileprintingrecords;
numbervar hours := hours+val(mid("00:15:18",1,2));
numbervar mins := hours+val(mid("00:50:18",4,2));
numbervar secs := hours+val(mid("02:11:18",7,2));

To display it:
whileprintingrecords;
numbervar hours ;
numbervar mins ;
numbervar secs ;
totsec := remainder(secs,60)
totmins := remainder(mins/60)+truncate(secs/60)
tothours := hours+truncate(secs/60)
totext(tothours,"",0)+":"+totext(totmins,"",0)+":"+totext(totsecs,"",0)+":"+

-k
 
Thanks, I did something like you said, but used the timeserial function in the end :

Lets say I have a formula that gives me the number of seconds in my fields (i.e. 00:11:18 = 678 sec)
{@Time to sec}

I call the function
TimeSerial(0,0, Sum ({@Time to sec}) )

which gives me the time I want!

Thanks for your reply!

Simon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top