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

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

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
6
Views
40
Replies
4
Views
61
Replies
1
Views
26
Replies
1
Views
63
Replies
2
Views
155

1,129,766
Messages
5,638,236
Members
417,016
Latest member
Tegguy

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.

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