Need assistance calculating number of days with several variables

cmacnab

New Member
Joined
Jun 24, 2013
Messages
46
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

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

jtakw

Well-known Member
Joined
Jun 29, 2014
Messages
6,038
Office Version
  1. 2016
Platform
  1. Windows
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)
 
Learn Excel from Bill Jelen

Understanding data is crucial, and the easiest place to start is with Microsoft Excel.

Forum statistics

Threads
1,151,608
Messages
5,765,402
Members
425,282
Latest member
Nibblesy

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
Top