Number of days per quarter between 2 dates

dunDaan

New Member
Joined
Dec 12, 2018
Messages
3
Can someone help me to calculate the number of days per quarter between 2 dates?

Start dateEnd dateQ1Q2Q3Q4
01 jan 201930 jun 2019899100
01 feb 201901 mar 201928000
01 feb 201901 aug 2019589100
01 nov 201801 aug 2019150-150060
01 jul 201931 dec 2019009192

<tbody>
</tbody>

I'm currently using following formula's:

For Q1: =MIN(MAX(DATE(YEAR(A2),4,0)-A2,0),B2-A2)
For Q2: =MIN(MAX(DATE(YEAR(A2),7,0)-A2,0),B2-A2)-C2
For Q3: =MIN(MAX(DATE(YEAR(A2),10,0)-A2,0),B2-A2)-SUM(C2:D2)
For Q4: =MIN(MAX(DATE(YEAR(A2),13,0)-A2,0),B2-A2)-SUM(C2:E2)

This returns the values as seen in table above so it works quite well, however as you can see this is not working OK when the dates are not within the same year. (see 5th row)

Any suggestions to make this work for all possible dates? It is expected that end date > start date, so no need to account for end date < start date

Thanks in advance.

/dunDaan
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
however as you can see this is not working OK when the dates are not within the same year. (see 5th row)

Hi, welcome to the forum!

You didn't tell us what results you expect for the 5th row - but assuming you want to disregard the year and apportion all of the days into their respective quarter here is an option you can try (formula in C2 copied down and across).


Excel 2013/2016
ABCDEF
1Start dateEnd dateQ1Q2Q3Q4
201/01/201930/06/2019899100
301/02/201901/03/201928000
401/02/201901/08/20195891320
501/11/201801/08/201990913260
601/07/201931/12/2019009192
701/01/201831/12/2019179182184184
Sheet1
Cell Formulas
RangeFormula
C2=SUMPRODUCT(0+("Q"&ROUNDUP(MONTH(ROW(INDIRECT($A2+1&":"&$B2)))/3,0)=C$1))
 
Last edited:
Upvote 0
Thanks for the fast response FormR.

Indeed I wasn't completely clear in what the intended values should be.
The intention is that the cells in columns C through F show how many days each quarter has, based on the start date and end date indicated in columns A end B for a specific year (in this case 2019).

Knowing that the interval between start date and end date will not exceed 1 year, your solution works perfectly, thanks a lot!!
I will now dig in trying to understand what the formula actually does :p
 
Upvote 0
FormR, very elegant! The approach wasn't obvious, so it was a learning experience. Thanks
 
Last edited:
Upvote 0
for a specific year

Hi, in that case, this approach might be better (more efficient). In this example the specific year is stored in cell C1.


Excel 2013/2016
ABCDEF
12019
2
3Start dateEnd dateQ1Q2Q3Q4
401/01/201930/06/2019899100
501/02/201901/03/201928000
601/02/201901/08/20195891320
701/11/201801/08/20199091320
801/07/201931/12/2019009192
920/12/201830/04/202090919292
Sheet1
Cell Formulas
RangeFormula
C4=MAX(0,MIN($B4,DATE($C$1,1+(COLUMNS($C4:C4)*3),0))-MAX($A4,DATE($C$1,1+((COLUMNS($C4:C4)-1)*3),0)))
 
Upvote 0
Technically you're right, but for my purpose it doesn't really matter whether or not the first day is included.
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,607
Members
449,090
Latest member
vivek chauhan

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