Microsoft KB Archive/94662

{|
 * width="100%"|

XL: Formulas that Return the Last or First Day of a Month

 * }

-

The information in this article applies to:


 * Microsoft Excel 98 Macintosh Edition
 * Microsoft Excel 97 for Windows
 * Microsoft Excel for Windows 95, versions 7.0, 7.0a
 * Microsoft Excel for the Macintosh, versions 2.2, 3.0, 4.0, 5.0, 5.0a
 * Microsoft Excel for Windows, versions 2.x, 3.0, 4.0, 4.0a, 5.0, 5.0c
 * Microsoft Excel for OS/2, versions 2.x and 3.0

-

SUMMARY
To create a formula that returns the last or first day of the current month, follow the appropriate procedure below.

Microsoft Excel Version 4.0 or Later
In Microsoft Excel 4.0 or later, you can use the EOMONTH function to return the last day of the current month. For example, the following formula

  =EOMONTH(TODAY,0)

returns the last day of the current month. Because the second argument(the MONTHS argument) is 0 (zero), the function assumes that the month you want to use is the current month. If the second argument is one (1), the function will return the last day of the following month.

To find the first day of the following month, use the EOMONTH function as follows:

  =EOMONTH(TODAY,0)+1

Microsoft Excel Version 3.0 or Earlier
To return the last day of the current month, use the following formula:

  =DATE(YEAR(NOW),MONTH(NOW)+1,1)-1

To find the first day of the following month, use the following formula:

  =DATE(YEAR(NOW),MONTH(NOW)+1,1)

For more information about the EOMONTH function, see pages 133-134 of the version 4.0 &quot;Microsoft Excel Function Reference.&quot;