Find number of days in a date range but only for a specific Month

Aviles

Board Regular
Joined
Dec 17, 2008
Messages
165
Hi all,

I'm looking for a formula to find the number of days within a date range, but only for a specific month (in this case, July):

[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD]Start Date[/TD]
[TD]End Date[/TD]
[TD]Expected
Result (days)[/TD]
[/TR]
[TR]
[TD]28/06/2019[/TD]
[TD]27/08/2019[/TD]
[TD]31[/TD]
[/TR]
[TR]
[TD]15/07/2019[/TD]
[TD]15/10/2019[/TD]
[TD]17[/TD]
[/TR]
[TR]
[TD]01/03/2019[/TD]
[TD]10/07/2019[/TD]
[TD]10[/TD]
[/TR]
</tbody>[/TABLE]

In this instance I'm only looking for the number of days in July, but this will change and I would like to easily change the formula to suit other months.

Thanks in advance.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Try My Array formula (Ctrl+Shift+Enter)
supposing that your data in cells a1 and b1
Code:
=SUMPRODUCT(IF(MONTH(ROW(INDIRECT(A1&":"&B1)))=7,1,0))
 
Last edited:
Upvote 0
For a non-volatile option, you could try this.

Change A1 for a different month.

Excel Workbook
ABC
1July
2
3Start DateEnd DateResult (days)
428/06/201927/08/201931
515/07/201915/10/201917
61/03/201910/07/201910
Days
 
Last edited:
Upvote 0
.. or for a non-volatile version of the post 2 formula, and also using a single cell to change the month-of-interest, you could try this.
Note that this also does not require the Control+Shift+Enter confirmation.

Excel Workbook
ABC
1June
2
3Start DateEnd DateResult (days)
428/06/201927/08/20193
515/07/201915/10/20190
61/03/201910/07/201930
Days (2)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,949
Messages
6,175,581
Members
452,653
Latest member
craigje92

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