Calculating Days In A Month Between 2 Date Ranges

slinky

Active Member
Joined
Dec 19, 2008
Messages
294
Morning folks,

I've managed to sort the first half of this issue, in that I can calculate the number of days within a given month which fall inside specified to and from date parameters..

The formula I've used is thus :
Code:
=IF(EOMONTH(A13,0)<(EOMONTH($H$9,-1)+1),0,IF(EOMONTH($H$9,0)=EOMONTH(A13,0),EOMONTH(A13,0)-$H$9+1,IF(EOMONTH(A13,0)>EOMONTH($I$9,0),0,IF(EOMONTH(A13,0)>$I$9,$I$9-(EOMONTH($I$9,-1)),EOMONTH(A13,0)-(EOMONTH(A13,-1))))))

This examines a date value (A13 in this case) and assess whether any days within that month are between the two date parameters specified in H9 and I9.

H9 = 01/01/2011
I9 = 15/05/2011

Jan-11
31
Feb-1128
Mar-11
31
Apr-1130
May-11
15
Jun-11
0
Jul-11
0

<colgroup><col><col></colgroup><tbody>
</tbody>

What I need to do now is specify a second set of date parameters in H10 and I10 and add those into the assessment. The dates will NOT overlap.

So, for example, if I were to set H10 as 01/07/2011 and I10 as 15/07/2011, the results would appear as below

Jan-1131
Feb-1128
Mar-1131
Apr-1130
May-1115
Jun-110
Jul-1115

<colgroup><col><col></colgroup><tbody>
</tbody>
Any thoughts?
Excel 2k3 btw..

TIA

<colgroup><col><col></colgroup><tbody>
</tbody>
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Thanks for your suggestion. A user of another board posted this nice solution which works perfectly.

=MAX(0,MIN(EOMONTH(A13,0),$I$9)-MAX(DATE(YEAR(A13),MONTH(A13),1),$H$9)+1)+MAX(0,MIN(EOMONTH(A13,0),$I$10)-MAX(DATE(YEAR(A13),MONTH(A13),1),$H$10)+1)
 
Upvote 0

Forum statistics

Threads
1,215,497
Messages
6,125,160
Members
449,209
Latest member
BakerSteve

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