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 IamaSherpa 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
 
Hi,

If you are using either Crystal 8 or 8.5 there are some date calculations that will help up out with this.

There is a datediff function that will take the difference in seconds and then you can convert that back to hours and minutes.

Hope this helps,

alley
 
I'm doing something similar. First I created a formula, as alley211 suggested with the datediff: (we'll call it @Secs)

DateDiff ("s", {InDateTime}, {OutDateTime})
// the "s" is for seconds

Then I have another formula that covers this to HH:MM:SS format:

WhilePrintingRecords;
NumberVar TotalSec := {@Secs};
NumberVar Hours := Truncate (Remainder ( TotalSec,86400) / 3600);
NumberVar Minutes := Truncate (Remainder ( TotalSec,3600) / 60);
NumberVar Seconds := Remainder ( TotalSec , 60);

Totext ( Hours, '00', 0,'') + ':'+
Totext ( Minutes,'00', 0,'') + ':'+
Totext ( Seconds,'00', 0,'')

Good Luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top