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

Time formula

Status
Not open for further replies.

BROWNIE56

Programmer
Dec 28, 2000
31
US
I need to show a total time of two visits (example in a doctors off, time in and time out, then show the total time of the visit)

Visit time in: case_vis_in (varchar) 1515 (time in table)
Visit time out: case_vis_out (varchar) 1600 (time in table)

I need to be able to display the total time of the visit, example 1:10 (1 hour , 10 minutes)

Thank you
 
Does 1515 represent 3:15pm?

Separate each field into hours and minutes and mutiply each component to get to seconds since midnight. Subtract seconds IN from seconds OUT to get a duration in seconds. Then use the formula in faq149-243 to turn your seconds back into an elapsed time string. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
If the field is always 4 characters:

Val ( {Field} [1 to 2] ) //will give you hours since midnight

Val ( {Field} [3 to 4] ) //will give you minutes

A little multiplication and addition will give you seconds since midnight for both in and out. Then you can do your subtraction and follow the FAQ. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top