Exceljet

Quick, clean, and to the point

Days in month

Excel formula: Days in month
Generic formula 
=DAY(EOMONTH(date,0))
Explanation 

To get the number of days in a given month from a date, you can use a formula based on the EOMONTH and DAY functions.

In the example shown, the formula in cell B5 is:

=DAY(EOMONTH(B5,0))

How this formula works

The DAY function returns the day component of a date.  The EOMONTH function returns the last day of the month for a given date. So, in this formula EOMONTH first returns a date corresponding to the last day of the month, and then DAY returns the date value for that date.

By definition, the value returned by DAY is always equal to the number of days in the month, since the date supplied to DAY is always the last day.

Author 
Dave Bruns

Excel Formula Training

Formulas are the key to getting things done in Excel. In this accelerated training, you'll learn how to use formulas to manipulate text, work with dates and times, lookup values with VLOOKUP and INDEX & MATCH, count and sum with criteria, dynamically rank values, and create dynamic ranges. You'll also learn how to troubleshoot, trace errors, and fix problems. Instant access. See details here.