Skip to Content
0
Former Member
Jun 12, 2008 at 09:04 PM

Surgical hours crosstab report - how to get time in 'buckets'?

31 Views

I have an need to create a report that is pulling from a database of case times for a hospital. We have a start time and end time (and dates) and the location of care (OR 1, OR 2, etc.). I want to generate a report for by month in the following format:

Hour Range: 0700-0759 0800-0859 0900-0959 etc.

-


Location

OR 1 10 15 12

OR 2 15 12 7

etc.

I see where these will not line up. The numbers after the location 'codes' (OR 1, etc.) are the totalled hours of all the cases that occurred in that OR for that time period (7am to 7:59am).

I have no trouble figuring out the how to do the initial - say 7:15 start in OR 1, case ending at 9:30. So I create a variable called H07 and subtract 7:15 from 8 giving me 45 minutes. I can do the same for the ending time of 9:30 - (9:30 from 10 - the 'end' of that group) and storing 30 minutes in an H09 variable. But what's got me stumped is that hour(s) that exists between the start and end times - I need to put 60 minutes in the H08 variable also. I know I can get the total elapsed time by subtracting the ending time from the beginning time and I've also written code to test for date changes (past midnight) to help deal with that issue. By just calculating an elapsed time of (in this example) 2 hours and 15 minutes I could 'walk' it up from 7:15 - I feel like I'm so close but I just haven't had an 'a-hah' moment yet. Any ideas out there? Thanks!

Edited by: Steve Gray on Jun 12, 2008 4:07 PM