FormulaCraft

How to find the number of days in a month in Excel and Google Sheets

Excel & Google Sheets
=DAY(EOMONTH(A2,0))

Try it with your data

Edit the grid or formula, then run it through a real spreadsheet engine — no signup.

Sample data — click any cell to edit

Runs server-side · free · no signup

Step by step

  1. 1Enter a date in column A (e.g., A2 = 2024-02-01). This can be any date within the month you want to measure.
  2. 2In the result cell, enter =DAY(EOMONTH(A2,0)). EOMONTH(A2,0) returns the last day of the same month as A2, and DAY() extracts its day number.
  3. 3Press Enter. The result is the total number of days in that month (e.g., 29 for February 2024, a leap year).

Tips

Need it for your exact data?

Describe your columns in plain English and get the precise formula for your sheet, with the right Excel or Sheets syntax.

Frequently asked

Does this formula handle leap years automatically?

Yes. EOMONTH always calculates the true last day of the month, so February returns 29 in leap years and 28 otherwise.

What if my date is stored as text?

Wrap it in DATEVALUE: =DAY(EOMONTH(DATEVALUE(A2),0)) to convert text to a proper date first.

Formulas used

Written and reviewed by FormulaCraft Team. Each formula on this page is run through our verification engine before publishing.

Last reviewed: