Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Formula

Status
Not open for further replies.

ridge

Technical User
Jan 31, 2000
91
0
0
US
Lookiong for a formula that will count the months between two specific dates...

ie: 1/31/81
11/30/12

how many months is this?...
 
How about:
[pre]
A B C

1/31/1981 11/30/2012 [blue]=(B2-A2)/30[/blue]
[/pre]
Assuming 30 days per month

Have fun.

---- Andy
 
Ah, the devil is in the details!

Exactly what do you mean by "months between two specific dates?" There is not necessarily one answer.

How about:

1/31/2012 2/1/2012
1/31/2012 2/28/2012
1/31/2012 3/1/2012


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
flushed with the success of being able to answer (poorly) an earlier question in this forum, here is my attempt at a formula which will count the number of whole months and append a fraction based on a 30 day month. changing the 30 to 100 would 'fake' the decimal to reflect the actual number of days

Code:
//assume the earlier date is called date1 and the later date is called date2
=((YEAR(date2)-YEAR(date1))*12)+MONTH(date2)-MONTH(date1) + ((DAY(DATE(YEAR(date1),MONTH(date1)+1,)) - DAY(date1) + DAY(date2))/30)
 
You could use YEARFRAC(Date1,Date2,Base)*12. Depending on rules (Date1=Date2 case, result 0 or 1) you can need Date1-1 instead of Date1. Base is an integer within 0-4, depending on calendar rules. You may need an Analysis Toolpak add-in installed.

combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top