# Need assistance calculating number of days with several variables

#### cmacnab

##### New Member
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
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)

Replies
4
Views
83
Replies
3
Views
203
Replies
2
Views
692
Replies
3
Views
123
Replies
2
Views
155

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

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.

### Which adblocker are you using?

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

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