Difference between two dates

Dochia

New Member
Joined
Apr 2, 2022
Messages
4
Office Version
  1. 2016
Platform
  1. Windows
Hi there,

I need help calculating the difference between two dates. I need to find out how many days a patient has been in our facility based on the entry /discharge dates within the month of November 2021 for example. Below are the entry/discharge dates and the number of days I need to obtain. I also included the formula which I tried, however, doesn't work properly under all scenarios. Any help/comment is much appreciated. Many thanks.
1651316330011.png
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
It's too bad you did not show row and column headers. It is always helpful to paste in actual data, better than pictures. I will assume Beginning Period is P5, and End Period is Q5, and Entry Date is column M and Discharge is N.

Your last example of 14 is incorrect, should be 15.

Note that my dates are in U.S. format.

$scratch.xlsm
MNOPQ
7BeginningEnd
811/1/202111/30/2021
9
10EntryDischargeNo of Days
1110/1/202130
1211/16/202112/21/202115
1311/3/202111/26/202124
1411/1/202130
159/28/202111/15/202115
Stay Duratoin
Cell Formulas
RangeFormula
O11:O15O11=MIN(N11,$Q$8)-MAX(M11,$P$8)+1
 
Upvote 0
Hi , Sorry about not including the rows numbers, and I forgot to mention : when the pacient is discarged we do not count the day because we don't charged them: they need to stay overnight in order for us to charged them .So for the last I need to get 14 days not 15 days , please.

Thank you for your swift reply and help!!
 
Upvote 0
OK try this

$scratch.xlsm
MNOPQ
7BeginningEnd
811/1/202111/30/2021
9
10EntryDischargeNo of Days
1110/1/202130
1211/16/202112/21/202115
1311/3/202111/26/202123
1411/1/202130
159/28/202111/15/202114
Stay Duratoin
Cell Formulas
RangeFormula
O11:O15O11=MIN(N11,$Q$8)-MAX(M11,$P$8)+IF(OR(N11<=$P$8,N11>=$Q$8),1,0)
 
Upvote 0
Thank you so much !!!Much appreciated your swift reply and help !!
 
Upvote 0
Are you sure that works how you want?

Below I have used that formula in column O and by my understanding the last two values are incorrect?
If I am right then an alternative version is given in column P

22 05 02.xlsm
MNOPQ
7BeginningEnd
81/11/202130/11/2021
9
10EntryDischarge6SJPSSs
111/10/20213030
1216/11/202121/12/20211515
133/11/202126/11/20212323
141/11/20213030
1528/09/202115/11/20211414
1628/09/20211/11/202110
173/11/202130/11/20212827
Days
Cell Formulas
RangeFormula
O11:O17O11=MIN(N11,$Q$8)-MAX(M11,$P$8)+IF(OR(N11<=$P$8,N11>=$Q$8),1,0)
P11:P17P11=MIN(N11,Q$8)-MAX(M11,P$8)+OR(N11<P$8,N11>Q$8)
 
Upvote 0
Solution
You're welcome. Thanks for the confirmation. :)
 
Upvote 0

Forum statistics

Threads
1,214,905
Messages
6,122,174
Members
449,071
Latest member
cdnMech

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top