How to get the number of days in a month
✓ Verified in LibreOffice 25.8.7.3Return how many days are in the month of a given date (handles leap years).
The formula
| App | Formula | Notes |
|---|---|---|
| Excel | =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. Every formula here is confirmed by actually executing it.