calculate number of months in a period using months

Discuss the spreadsheet application

calculate number of months in a period using months

Postby cicade » Mon May 19, 2008 9:04 pm

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
OOo 3.0.X on Mac OSx Leopard + Ubuntu, Win XP
cicade
 
Posts: 41
Joined: Tue Nov 27, 2007 9:05 am
Location: Netherlands

Re: calculate number of months in a period using months

Postby Villeroy » Mon May 19, 2008 9:50 pm

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   Expand viewCollapse view
=YEAR(B1)*12+MONTH(B1)-YEAR(A1)*12-MONTH(A1)

Of course this can not work with literal text values.
Test:
Code: Select all   Expand viewCollapse view
=COUNT(A1:B1)

returns 2 if both cells have a numeric value (such as valid date).
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.4
User avatar
Villeroy
Volunteer
 
Posts: 28544
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany


Return to Calc

Who is online

Users browsing this forum: ThatRedMelon, Zizi64 and 16 guests