Penny32 said:
have tried different formats for the dates, always comes up the same. have
formated in date/time format,
=(YEAR(10/16/2015)-YEAR(05/11/2009))*12+MONTH(10/16/2015)-MONTH(05/11/2009)=
1/0/1900.....what is wrong here?
As others have already responded, without double quotes, Excel
evaluates 10/16/2015 as the arithmetic expression (10 divided by 16)
divided by 2015 = 0.000310173697270471, so YEAR(10/16/2015) = 1900.
Same for YEAR(5/11/2009). So (YEAR(10/16/2015)-YEAR(05/11/2009))*12 =
0. Likewise, MONTH(10/16/2015) and MONTH(05/11/2009) both equal 0. So
your formula returns 0, which when formatted as a date displays as
1/0/1900.
On my system, running Excel 2003, the formula
=(YEAR("10/16/2015")-YEAR("05/11/2009"))*12+MONTH("10/16/2015")-MONTH
("05/11/2009")
returns 77. FWIW, so does the formula
=DATEDIF("05/11/2009","10/16/2015","M")
and (less robust)
=INT(("10/16/2015"-"05/11/2009")/30.436875)
where 30.436875 = (97*366+303*365)/(400*12), the average number of
days in the standard 400 year Gregorian calendar cycle.