Spreadsheet Practice

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 to E6
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

  1. $B$24/10/2026

    The value in B2.

  2. D2Jan 2026

    The value in D2.

  3. EOMONTH(D2,0)1/31/2026 (46053)

    EOMONTH: Last day of the month, months away.

    • start_dateD2Jan 2026
    • months0
  4. MIN($B$2,EOMONTH(D2,0))46053

    MIN: Smallest number.

    • number1$B$24/10/2026
    • number2EOMONTH(D2,0)1/31/2026 (46053)
  5. $B$11/20/2026

    The value in B1.

  6. MAX($B$1,D2)46042

    MAX: Largest number.

    • number1$B$11/20/2026
    • number2D2Jan 2026
  7. MIN($B$2,EOMONTH(D2,0))-MAX($B$1,D2)11

    The - operator subtracts.

  8. MIN($B$2,EOMONTH(D2,0))-MAX($B$1,D2)+112

    The + operator adds.

  9. MAX(0,MIN($B$2,EOMONTH(D2,0))-MAX($B$1,D2)+1)12

    MAX: Largest number.

    • number10
    • number2MIN($B$2,EOMONTH(D2,0))-MAX($B$1,D2)+112

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.

FormulaResultWhen to use it
=MAX(0,NETWORKDAYS(MAX($B$1,D2),MIN($B$2,EOMONTH(D2,0))))9, 20, 22…Different resultWorking 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)+1 in 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

In 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.