# Google Sheets: Generate Number of Days in a Month

You can use the following basic formula to generate the number of days in a month in Google Sheets:

`=DAY(EOMONTH(A2,0))`

This particular formula calculates the number of days in the month for the date in cell A2.

Note: The EOMONTH function returns the date representing the last day of the month and the DAY function returns the value for the day of the month.

The following example shows how to use this formula in practice.

## Example: Generate Number of Days in a Month in Google Sheets

Suppose we have the following dataset in Google Sheets:

Now suppose that we would like to create a new column that contains the number of days in the month for each value in the Date column.

To do so, we can type the following formula into cell C2:

`=DAY(EOMONTH(A2,0))`

We can then drag and fill this formula down to each remaining cell in column C:

Column C now displays the number of days in the month for each value in the Date column.

For example:

• There are 31 days in the month that 1/14/2022 occurs on (January)
• There are 28 days in the month that 2/13/2022 occurs on (February)
• There are 31 days in the month that 3/15/2022 occurs on (March)

And so on.