How to calculate how many days of a date range fall in each month in Excel
Formula (Excel and Google Sheets)
=MAX(0,MIN($B$2,EOMONTH(D2,0))-MAX($B$1,D2)+1)Overlap the range with each month: =MAX(0,MIN($B$2,EOMONTH(D2,0))-MAX($B$1,D2)+1), with the month's first day in D2.
- Result on the example
- one result per row in
E2, filled down toE6 - Works in
- Every current version
- Google Sheets
- Same formula
See it work
The formula is already in E2, filled down to E6. Change any input and the result updates, or edit the formula to experiment.
How it works
For each month, the overlap starts at the later of the range start and the month start, and ends at the earlier of the range end and the month end. Their difference plus 1 is the number of days in that month, and MAX(0, …) returns 0 for months outside the range. The days add up to 81, the length of the whole range.
=MAX(0,MIN($B$2,EOMONTH(D2,0))-MAX($B$1,D2)+1)Result12
$B$24/10/2026The value in B2.
D2Jan 2026The value in D2.
EOMONTH(D2,0)1/31/2026 (46053)EOMONTH: Last day of the month, months away.- start_date
D2Jan 2026 - months
0
- start_date
MIN($B$2,EOMONTH(D2,0))46053MIN: Smallest number.- number1
$B$24/10/2026 - number2
EOMONTH(D2,0)1/31/2026 (46053)
- number1
$B$11/20/2026The value in B1.
MAX($B$1,D2)46042MAX: Largest number.- number1
$B$11/20/2026 - number2
D2Jan 2026
- number1
MIN($B$2,EOMONTH(D2,0))-MAX($B$1,D2)11The - operator subtracts.
MIN($B$2,EOMONTH(D2,0))-MAX($B$1,D2)+112The + operator adds.
MAX(0,MIN($B$2,EOMONTH(D2,0))-MAX($B$1,D2)+1)12MAX: Largest number.- number1
0 - number2
MIN($B$2,EOMONTH(D2,0))-MAX($B$1,D2)+112
- number1
In Google Sheets
The same formula works in Google Sheets: =MAX(0,MIN($B$2,EOMONTH(D2,0))-MAX($B$1,D2)+1). We ran it in Google Sheets mode on the same data and it returns the same results.
Other ways to do it
Each one was run on the same example sheet.
| Formula | Result | When to use it |
|---|---|---|
| =MAX(0,NETWORKDAYS(MAX($B$1,D2),MIN($B$2,EOMONTH(D2,0)))) | 9, 20, 22…Different result | Working days in each month instead of calendar days. Counts weekdays only. |
Common mistakes
- Without the +1 every month is a day short, because both ends of the overlap count.
- Column D must hold the first day of each month. Use
EOMONTH(D2,-1)+1in place of D2 if it might not.
Try it yourself
Same data, empty answer cell. Your formula is graded instantly, then re-checked on changed data, so a typed-in number won't pass.
Calculate how many days of a date range fall in each month
E2, count how many days of the range from B1 to B2 fall in the month starting on D2, and fill down to E6.Questions
How do I split an amount across the months?
Share it by days: =amount*E2/SUM($E$2:$E$6).
How do I check the total?
=SUM(E2:E6) should equal B2-B1+1.
Checked by running on 2026-10-30: every formula and result on this page was calculated by the Spreadsheet Practice formula engine, in both Excel and Google Sheets modes.