![]() |
|
|||||||
![]() |
|
Is there a single option to get difference in two dates in terms of years months...
|
![]() |
LinkBack | Thread Tools | ![]() |
Display Modes | ![]() |
|
|||
|
...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?
|
| Links |
|
|
|
|||
|
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. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|