会員登録(無料)
ログイン
Improve your skills, click here now!

Counting the number of days in a month by combining the DAY and EOMONTH functions (spreadsheet)

To count the days of a month using a combination of functions DAYin Google Sheets , follow these steps:EOMONTHtable of contents

Using the EOMONTH function

Using the EOMONTH function : EOMONTHThe function returns the date of the last day of a particular month.

This function takes as arguments a specific date (e.g. “2024-02-01”) and a number to add or subtract the month (0 is the month, 1 is the next month, -1 is the previous month).

For example, =EOMONTH("2024-02-01", 0)returns the last day of February 2024, the date from which to calculate the number of days in February 2024.

=EOMONTH("2024-02-01", 0)

Using the DAY function

Using the DAY function : DAYThe function returns the “day” part of a date as a number. By inputting the output from the function into this function EOMONTH, you can get the number of days in the month.

For example, =DAY(EOMONTH("2024-02-01", 0))returns the number of days in February 2024, or 29 (in a leap year).

=DAY(EOMONTH("2024-02-01", 0))

Therefore, if you want to find the number of days in any month, EOMONTHenter the first day of the month (e.g. “2024-02-01”) into the function and DAYuse the function to get the day of the last day of the month.

This will calculate the number of days in the month.

A concrete example of calculating the number of days

Let me give you a concrete example of calculating the number of days in March 2024.

Select any cell in your spreadsheet.

Enter the following formula into that cell:

=DAY(EOMONTH("2024-03-01", 0))

In this formula, EOMONTHthe function calculates the last day of the month starting from March 1, 2024. The function then DAYreturns the “day” part of that last day as a number.

Press the Enter key to display the calculation results. There are 31 days in March 2024, so the result will be “31”.

summary

This method can be used for any year and month. For example, if you want to know the number of days in July 2025, =DAY(EOMONTH("2025-07-01", 0))enter the formula as In this way, you can easily calculate the number of days in different months and years.