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

time formula help (addition) 2

Status
Not open for further replies.

lareya

Technical User
Jan 30, 2003
49
US
Can someone help me with a formula that will add some time up for me?

{POST_CASE.ENTER_PROC_ROOM_TIME} enter Rm time
{POST_CASE.LEAVE_PROC_ROOM_TIME} Lv Rm time

I use these fields for times on the report. I need to have a formula that will see the first 30 min and then see the remaining time in 15 minute increments.

so level for 1 hour would be this
30 min 1
15 min 2

And if it is more than 10 minutes, it get's rounded up to the 15 minutes.

so 1 hour and 40 minutes would yield this
30 min 1
15 min 5
Thank you for any help you can give me.

Lareya


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Crystal XI; SQL database; MS Windows 2K; ORSOS/One Call Hospital Scheduling System v10.1.2; Huge Newbie to Crystal! Operating Room RN Analyst
 
You need to post an example of what's in the fields, and the data type of the fields.

It should be relatively easy to do this, but I don't want to start down the wrong path...

-k
 
Okay,
the {POST_CASE.ENTER_PROC_ROOM_TIME} & {POST_CASE.LEAVE_PROC_ROOM_TIME}
they are both date time fields that are formated to this 13:23

fields show this on a report
11:15 Room Time in (the words are my titles)
11:59 Room Time out

thanks!

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Crystal XI; SQL database; MS Windows 2K; ORSOS/One Call Hospital Scheduling System v10.1.2; Huge Newbie to Crystal! Operating Room RN Analyst
 
I guess I am looking for is a formula that goes like this (quasi code)

If the case is more than 30 minutes then 1
and if the case goes longer, break it up into 15 minute increments rounding up past 10 minutes.

and it would show this

level 30 1
15 4

or 30 -1 15 -4

or anything that shows that there is one of 30 minutes and 4 of 15 minute increments rounded up.

I work with only one record at a time.

Thanks
Lareya

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Crystal XI; SQL database; MS Windows 2K; ORSOS/One Call Hospital Scheduling System v10.1.2; Huge Newbie to Crystal! Operating Room RN Analyst
 
Try the following. I wasn't sure what you wanted to show if the minutes were less than 30, so I set this up to display the actual minutes if less than 30:

numbervar timex := datediff("n",{POST_CASE.ENTER_PROC_ROOM_TIME},{POST_CASE.LEAVE_PROC_ROOM_TIME});
numbervar min30;
numbervar min15;
stringvar display;

if timex-30 > 0 then (
min30 := 1;
if remainder((timex-30),15) < 10 then
min15 := truncate((timex-30)/15) else
min15 := -int(-(timex-30)/15));
if timex-30 < 0 then
display := "Total Mins: "+totext(timex,0,"") else
display := "30 Mins: "+ totext(min30,0,"")+ chr(13)+ "15 Mins: "+ totext(min15,0,"");

I added a return in the display, so be sure to format the formula to "can grow" (format field->common->can grow).

-LB
 
OK, here's the basics:

whileprintingrecords;
numbervar TotalTime:= datediff("n",{POST_CASE.ENTER_PROC_ROOM_TIME}, {POST_CASE.LEAVE_PROC_ROOM_TIME});
// now we have the number of minutes diference
numbervar T30:=0;
numbervar T15:=0;
If TotalTime > 30 then
T30:=1;
If TotalTime > 30 then
TotalTime:=TotalTime-30;
If Totaltime > 15 then
(
T15:= int(TotalTime/15);
TotalTime:=TotalTime-(int(TotalTime/15)*15);
);
If TotalTime >= 10 then
T15:=T15+1;
"30: " & T30 & chr(13) & "15: " & T15

-k
 
You both are BEAUTIFUL people! thank you thank you!
They both work, and plus I can learn from both examples!

Lareya!

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Crystal XI; SQL database; MS Windows 2K; ORSOS/One Call Hospital Scheduling System v10.1.2; Huge Newbie to Crystal! Operating Room RN Analyst
 
Just wanted to add that I changed the first line to check for time that spanned the midnight hour.

numbervar timex :=IF {POST_CASE.LEAVE_PROC_ROOM_TIME} < {POST_CASE.ENTER_PROC_ROOM_TIME} THEN
((TIME ({POST_CASE.LEAVE_PROC_ROOM_TIME}) + 86400)
- (TIME ({POST_CASE.ENTER_PROC_ROOM_TIME}))) /60
ELSE ((TIME ({POST_CASE.LEAVE_PROC_ROOM_TIME}) -
(TIME ({POST_CASE.ENTER_PROC_ROOM_TIME}))) /60;
) ;

from lbass example.
I was wondering if there was a more elegant formula then this? It works fine though like this.

Lareya

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Crystal XI; SQL database; MS Windows 2K; ORSOS/One Call Hospital Scheduling System v10.1.2; Huge Newbie to Crystal! Operating Room RN Analyst
 
I thought these were datetimes--if they are, then you should be able to use datediff, as in my suggestion.

-LB
 
hmm,
when I put my cursor over the field it reads the field and has (date time) come up. However, when I use your field as you suggested the span midnight doesn't work. It acts like it really is just a time field?

I rechecked my fields again. I went back into the format field and changed everything to 13:23 - but I still get a large negative number when I run it through a midnight span.

I think those fields must just be time fields, even tho like I said before, the Date Time label floats up when I put my cursor over it (along with the fields name).

Thanks tho!

Lareya

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Crystal XI; SQL database; MS Windows 2K; ORSOS/One Call Hospital Scheduling System v10.1.2; Huge Newbie to Crystal! Operating Room RN Analyst
 
What happens if you try to change the display of the field to date? What date appears? It may be that the field was set up with some constant as a date, with only the time changing--this would cause the results you are seeing.

-LB
 
Okay, I was able to change the format to this:
03/01/1999 gave this: 01/01/1800
01-March-1991 13:23 gave this: 01-Jan-1800 7:30

I have noticed that my time fields that are zero'd out are actually datetime(1800,01,01,00,00,00) to get the no time & date

Lareya

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Crystal XI; SQL database; MS Windows 2K; ORSOS/One Call Hospital Scheduling System v10.1.2; Huge Newbie to Crystal! Operating Room RN Analyst
 
So there is a constant date value. I think your solution should address the issue just fine.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top