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

Calculation of Time

Status
Not open for further replies.

JonathanNYC

IS-IT--Management
Mar 29, 2003
111
US
Several of you helped me with a formula to calculate time used in the OR only up to 7 p.m. There are instances when a case starts before 7 PM and ends after 7 PM and that calculation is accurate.

However, there are a few instances each month when a case starts AFTER 7PM. As such, it seems that I require one further tweak in my formula (see existing formulas below) because I am getting some negative numbers (e.g., case starts at 19:30 hours and my results are displaying -0.50). I understand that .50 is 30 minutes, but I want a result of 0:00 minutes (or no value).

Is there a way I can modify the formula so that 0:00 minutes are displayed (or no value is displayed) for any case that starts AFTER 19:00 hours?

Upto7PM formula:
datetimevar Mytime:={pcmOpTime.timePatientLeaveRoom};
timevar MaxTime:= time(19,0,0);
if time(MyTime) > MaxTime then
MyTime:=date(Mytime)+MaxTime;
MyTime

My Time formula:
evaluateafter({@upto7pm});
datetimevar MyTime;
datediff("n",{pcmOpTime.startSetup},MyTime)/60

I am using Crystal Reports 10.0.

Jonathan
 
Change this formula to:

My Time formula:
evaluateafter({@upto7pm});
datetimevar MyTime;
timevar MaxTime;
if time({pcmOpTime.startSetup}) >= MaxTime then 0 else
datediff("n",{pcmOpTime.startSetup},MyTime)/60

-LB
 
Thank you LB, I am close, but with your revised formula all my results are yielding 0, not just for the cases with a "startsetup time" of greater than or equal to MaxTime.

Do you suspect I am missing some syntax in my formula or need to verify my fields to make sure they are number fields or date fileds or time fields?

Thanks in advance. Jonathan
 
I don't see anything wrong with the formula as I suggested. I assume that the formula is placed in the same section or below the section containing the first formula.

-LB
 
Works perfectly. I had created a wholly new formula and name based on your recommendation and had placed it in another column of the report. I went back and revised and used the original formula you had given me. It now displays the data exactly as I wanted it Thanks again, much appreciated. Jonathan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top