I have a table with patient visits. On this table there is an admitting date/Time and a discharge Date/Time. I need to calculate how many hours patients were in the hospital during a 24 hour period.
For example: 24 hour period, June 02 12:00:01AM to June 03 12:00:01AM
Patient 1 was admitted June 1 at 5:00 PM and discharged June 5 at 1:00 PM. This patient spent 24 hours in the hospital for the 24 hour period I am looking at.
Patient 2 was admitted June 1 at 5:00 PM and discharged June 2 12:00:00PM. This patient spent 12 hours in the hospital for the 24 hour period I am looking at.
Patient 3 was admitted June 2 at 7:00 PM and discharged June 5. This patient spent 5 hours in the hospital for the 24 hour period I am looking at.