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!

accumulating time

Status
Not open for further replies.

Quickie67

Technical User
Dec 19, 2001
6
US
Can anyone help me figure out how to accumulate time.Like I clock in to work, and out for lunch, back in, then out to go home. I mean I can add it up

Example

A= in 1:00
B= out 2:00
C= in 2:30
D= out 4:00
T= total

T=A+D-B+C

But this wont work cause 1:00 + 4:00= 3 hours not 5 so theres something that i'm missing. Any help would be greatly appreciated.
quickie67
 
What about

B-A + D-C ???

or in general
(out - associated in) + (out - associated in) etc...

This assumes that for every out there is an in associated with it.

Matt
 
both of the equations work to get the correct answer. what i mean is I dont know how to set it up so that the program recognizes it as time rather than 1 colon 00 do you know what I mean?
 
Generally, to do it correctly, you'll need to parse the string, and in the process creating an integer variable containing the total minutes. Add or subtract these values as appropriate, then put the data back into string format for display.
 
ok now that was what I was looking for thank you so much
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top