Need assistance calculating number of days with several variables

cmacnab

Board Regular
Joined
Jun 24, 2013
Messages
57
Office Version
  1. 2016
Platform
  1. Windows
Hi all. I need to calculate the number of days based on several variables and I just can't get them all in there.

This would be based on a reference period, for example:
Period 01/01/21 to 01/31/21

There could be several options that I need to cover in my formula, so 4 different dates are referenced:

Dates ending after reference period: from 01/19/21 to 02/18/21 = 13 days based on period above
Dates starting before reference period: from 12/15/20 to 01/03/21 = 3 days based on period above
Dates outside of reference period: from 02/01/21 to 02/28/21 = 0 days based on period above
Dates starting before & ending after reference period: from 12/01/20 to 02/28/21 = 31 days based on period above

I hope that I'm clear, can someone help me with this? Thank you in advance.
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Hi,

Does this help:

Book3.xlsx
ABCDEF
9Reference StartReference EndDays
101/1/20211/31/20211/19/20212/18/202113
1112/15/20201/3/20213
122/1/20212/28/20210
1312/1/20202/28/202131
141/1/20211/31/202131
Sheet919
Cell Formulas
RangeFormula
F10:F14F10=MAX(0,DAYS(MIN(B$10,E10),MAX(A$10,D10))+1)
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,329
Members
452,635
Latest member
laura12345

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