# Calculate number of days between 2 dates depending on column header

#### surkdidat

##### Active Member
Hi

Hope someone can help!

In Column A I have a start date
In Column B I have an end date (can be blank if product is "live") - (I can "end date this to 31/12/9999 if needed

In Columns C onwards I have the months from April 2020 onwards

What I need is a formula that looks at the start date in column A, the end date in column B, and then uses the months in Columns C onwards to calculate how many days that particular product has been live.

So if a product launched on 30 January 2021, it would count 2 days for January 2021 (30 & 31), and 28 days for February 2021.

Ideally, if its live can it calculate on todays date (so if it is 1 March 2021 when doing this, it would count 1 day, and then on Tuesday update it to 2.?

### Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

#### Fluff

##### MrExcel MVP, Moderator
Excel Formula:
``=DAYS(IF(B2="",TODAY(),B2),A2)+1``

#### surkdidat

##### Active Member
Excel Formula:
``=DAYS(IF(B2="",TODAY(),B2),A2)+1``
Unfortunately, that doesn't take the months in column C onwards into account...

#### Dave Patton

##### Well-known Member
Headings are dates like Jan 1 2021 Feb 1 2021

T202006a.xlsm
ABCDE
8StartEndJan-2021Feb-2021Mar-2021
930-Jan-2131-Dec-2122831
1026-Feb-2128-Feb-21030
11
9a
Cell Formulas
RangeFormula
C9:E10C9=MAX(0, MIN(EOMONTH(C\$8, 0), \$B9) + 1 - MAX(C\$8, \$A9))
B10B10=TODAY()

#### surkdidat

##### Active Member
Headings are dates like Jan 1 2021 Feb 1 2021

T202006a.xlsm
ABCDE
8StartEndJan-2021Feb-2021Mar-2021
930-Jan-2131-Dec-2122831
1026-Feb-2128-Feb-21030
11
9a
Cell Formulas
RangeFormula
C9:E10C9=MAX(0, MIN(EOMONTH(C\$8, 0), \$B9) + 1 - MAX(C\$8, \$A9))
B10B10=TODAY()
Thanks very much!

#### Dave Patton

##### Well-known Member
Thanks for the feedback.

Replies
1
Views
56
Replies
2
Views
102
Replies
4
Views
48
Replies
2
Views
141
Replies
4
Views
274

1,127,596
Messages
5,625,714
Members
416,130
Latest member
galgozzi

### 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