View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Trevor Shuttleworth Trevor Shuttleworth is offline
external usenet poster
 
Posts: 1,089
Default number of months in a period

One way:

=IF(MONTH(B1)-MONTH(A1)=0,MONTH(B1)-MONTH(A1)+1,MONTH(B1)-MONTH(A1)+1+12*(YEAR(B1)-YEAR(A1)))

Note that the date in column B *must* be greater than or equal to the date
in column A

Regards

Trevor


wrote in message
oups.com...
I am trying to determine the number of months that are spanned in a
given period. For example, the number of months spanned in the period
16 Jun 06 to 17 Jul 06 is 2.

All the functions in Excel that I have found give the result as 31 days
or 1 month.

I am trying to avoid creating a lookup table that lists each month of
each year as the periods I need to look at will go up to and beyond
2018 (without me knowing) so ideally, the process needs to automated so
there are no tables to maintain.

I'd be grateful if anyone could advise how I can go about this.

Thanks