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

Time Calculation

Status
Not open for further replies.

newbie0423

IS-IT--Management
Oct 29, 2012
103
US
I am writing a report that shows the OR procedure performed from 7:00am to 5:00pm. Sometimes we have cases that start at 4:00pm and run past 5:00pm and I would like to incorporate those minutes as well . is there a code that could be written for this?


example
In room Out room total
3:10 5:44 154
I would like to only calculate 94 minutes.

Thank you

 
Try
Code:
DateDiff ("n", {date1},  {date2})
This will give you the difference in minutes.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 2008 with SQL and Windows XP [yinyang]
 
I have used the code in my report and it is giving me the total minutes that the procedure ran which is OK. I need to have the minutes only that the procedure ran over past 5:00 pm. for instance if a procedure started at 3:00 and ended at 6:00. I would like to see a total of 60 minutes because the staffing goes down at 5:00 pm.
I am using crystal XI
 
An example, hopefully helpful. Change the hour in the EndDateTime variable to see it work. Just create a formula and include on a report.

Code:
local dateTimeVar StartDateTime := datetime("3/22/2013 14:00:00pm");
local dateTimeVar EndDateTime   := datetime("3/22/2013 15:00:00pm");


if timevalue(EndDateTime) > TimeSerial(17,00,00)
then EndDateTime := DateTime( DateSerial(year(StartDateTime), month(StartDateTime), day(StartDateTime)), TimeSerial(17, 00, 00));

DateDiff ("n", StartDateTime,  EndDateTime)
 
Thanks very much for your help. I used the formula below from a previous post and it gave me exactly what I was looking for. Thanks again!

val(right(totext({@Time modified},"0000"),2)) +
(val(left(totext({@Time modified},"0000"),2))*60)


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top