View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
LauriS LauriS is offline
external usenet poster
 
Posts: 32
Default Calculating elapsed days and hours

I figured out a formula for this but now I wonder if there would have been an
easier way.

Here's the situation. I had four separate cells - Admit Date (A1), Admit
Time (B1), Discharge Date (C1), Discharge time (D1).

I needed to calculate the number of days and the number of hours/minutes
spent in the hospital.

(If a person checked in on 8/1 at 3:00 pm and checked out on 8/2 at 2:00 pm
- it was NOT 1 day - it was 0 days, 23 hours.)

So here is my forumula. To calculate the number of days spent in the
hospital:

=IF(C2-A20,IF(D2B2,DATEDIF(A2, C2, "D"),IF(D2=B2,C2-A2,C2-A2-1)),0)

To calculate the number of hours/minutes spent:

=IF(D20,IF(B20,IF(D2B2,D2-B2,(D2-0)+(12-B2)),0),0)

Was there an easier way??