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

String Total

Status
Not open for further replies.

EagerBeaver

Technical User
Apr 16, 2001
39
US
I need to total a time field which displays as: 00:00:00:00 I want to add these for the designated group and then also have a grand total. I cant seem to do a sum for this field, it is not an option, I cannot do a running total either. The field is string.

Please help.

K
 
Yes you can't sum a string. The only way to total this value is to convert this value to seconds, sum the seconds, and then convert it back to a formatted time string.

This will convert your string to seconds:

Val( {test1} [ 1 to 2])*24*60*60 +
Val( {test1} [ 4 to 5]) *60*60 +
Val( {test1} [ 7 to 8]) *60 +
Val( {test1} [10 to 11])

Now do a subtotal and grand total of this new formula.

Finally, to convert these totals back to a formatted date string, use the formula in my FAQ on common formulas. Ken Hamady
Crystal Reports Training/Consulting and a
Quick Reference Guide to VB/Crystal (including ADO)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top