← All how-to recipes

How to get the number of days in a month

✓ Verified in LibreOffice 25.8.7.3 ✓ Verified in Google Sheets (2026-08-30)

Return how many days are in the month of a given date (handles leap years).

The formula

AppFormulaNotes
Excel (desktop)=DAY(EOMONTH(A2,0))EOMONTH gives the last day of the month; DAY extracts its day number.
Google Sheets=DAY(EOMONTH(A2,0))Identical.
LibreOffice Calc=DAY(EOMONTH(A2,0))Identical.

How it works

EOMONTH(date, 0) returns the last day of that date's month; DAY() then reads its day-of-month number. February 2024 is a leap year, so it has 29 days. Put your date in A2 and use =DAY(EOMONTH(A2,0)).

Verified, not just documented

We ran =DAY(EOMONTH(DATE(2024,2,10),0)) in LibreOffice 25.8.7.3 (headless, with forced recalculation) and it returned 29 — exactly the expected result. We then ran the same formulas in Google Sheets, executed 2026-08-30: a formula-only workbook goes into Google Drive, which converts it to a Sheet and recalculates every formula with Google’s own engine, and comes back out as .xlsx carrying the values Google computed. It returned 29 for the worked example, the same value LibreOffice produced. Both engines’ numbers on this page are executed results. The Excel formula follows Microsoft’s official documented syntax — we do not run desktop Excel.

Functions used

DAY · EOMONTH — see full Excel, Google Sheets & LibreOffice compatibility for each.

Related recipes

Related comparisons