Page 1 of 1

calculate number of months in a period using months

Posted: Mon May 19, 2008 9:04 pm
by cicade
try to use MONTHS to calculate the number of months in a period (several years)
-what method should i use to write the date? dd-mm-yyyy? or mm-dd.yyyy?
- whatever I do the answer is 1 or -1 or 0 (if not code 504)

Question: does MONTHS calculate the number of months in a given period of time? What should I do to get a result?
(I did use the formula wizzard)

greetings from Cicade

Re: calculate number of months in a period using months

Posted: Mon May 19, 2008 9:50 pm
by Villeroy
I never used the MONTHS function. Having two dates in cells A1(earlier) and B1(later) and knowing for shure that every year has 12 months exactly:

Code: Select all

=YEAR(B1)*12+MONTH(B1)-YEAR(A1)*12-MONTH(A1)
Of course this can not work with literal text values.
Test:

Code: Select all

=COUNT(A1:B1)
returns 2 if both cells have a numeric value (such as valid date).