Go Back   Talk Microsoft > Microsoft Operating Systems & Software > Microsoft Office Family

Reply
     Is there a single option to get difference in two dates in terms of years months...  
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-27-2007, 07:27 PM
Junior Member
 
Join Date: Sep 2007
Posts: 2
Default Is there a single option to get difference in two dates in terms of years months...

...and days in Microsoft Excel? In Microsoft Excel, if for example 20 sep 2001 is subracted from 01 jan 2006 the answer will be in terms of number of days. I am resorting to Mod and Int functions to get the days into Years, Months and Days. Instead, is there any single function to straight away give the answer in terms of Years, Months and Days?
Reply With Quote
Links
  #2 (permalink)  
Old 09-27-2007, 08:04 PM
Junior Member
 
Join Date: Sep 2007
Posts: 9
Default

If your two dates are in A1 and A2, put the following formula in the cell in which you want the difference to appear:

=YEAR(A2)-YEAR(A1)-IF(OR(MONTH(A2)<MONTH(A1),AND(MONTH(A2)=MONTH(A1),
DAY(A2)<DAY(A1))),1,0)&" years, "&MONTH(A2)-MONTH(A1)+IF(AND(MONTH(A2)
<=MONTH(A1),DAY(A2)<DAY(A1)),11,IF(AND(MONTH(A2)<M ONTH(A1),DAY(A2)
>=DAY(A1)),12,IF(AND(MONTH(A2)>MONTH(A1),DAY(A2)<D AY(A1)),-1)))&" months,
"&A2-DATE(YEAR(A2),MONTH(A2)-IF(DAY(A2)<DAY(A1),1,0),DAY(A1))&" days"


I know, not pretty. :-) Here's where I got it, which also has other info on working with dates in Excel: http://support.microsoft.com/kb/214094

added: go to the article to copy the formula, I notice that Y!A truncated entire sections of it when I pasted.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 04:01 PM.