Month calculations: DATE() vs EDATE()
=DATE(YEAR(A1),MONTH(A1)+1,DAY(A1))
Yvan Koenig suggested instead using the simpler EDATE formula, here equivalent to:
EDATE(A1,1)
There is, as it turns out, more than simplicity in favor of Yvan's approach. While one might expect the two formulas always to produce the same results, they do not! This is easily seen by constructing the following three column table with a column header:
1. In cell A2, enter the last day of the first month of this year (January 31, 2008 in the U.S. system, for example). In the cell below it, enter the last day of the second month of this year (Feburary 29, 2008, for example).
2. Next, select both cells & use the circular fill handle, drawing down to fill the column with a year or so of last-day-of month values.
3. Select cell B1 (a header cell) & enter in the formula bar & press return:
=DATE(YEAR(A),MONTH(A)+1,DAY(A))
4. Likewise, in cell C1 enter:
=EDATE(A,1)
Note that the B & C column values are sometimes the same, sometimes not. The same results occur if the "1" in both formulas is replaced with another number of months.
What seems to be happening is the 'MONTH(A)+n' expression uses the number of days in the month of the "A" cell value as the basis for the 'n months later' calculation, which is not the convention usually used for such things as billing cycles. The EDATE formula follows the normal convention, & is thus the preferred choice for almost all uses imaginable ... unless perhaps you are the one being billed. 🙂
This also applies to 'YEAR(A) + n' calculations.
So, it would seem that any calculation involving the DATE(year, month, day) form with an arithmetic operator in the year or month element should be used only with great care, if at all.
BTW, the comments about the month unit of calendar time having "no real purpose today" in http://www.cl.cam.ac.uk/~mgk25/iso-time.html may be of interest.
iMac G5/2.0 GHz 17" ALS; White MacBook/2.4 GHz, Mac OS X (10.5.4), Kensington Trackball