![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Mar 2002
Posts: 33
|
Hello again,
I have a quick question. I am trying to determine the "difference" in Years and Months between two end dates (ie, subtract 1/2/1994 from 4/2/2002). When I subtract I get a decimal approximation (ie, 8.25.. where that would be roughly 8 years 3 months). HOw would I get Excel to convert this decimal value to a "YY years , MM months" format? Any help would be greatly appreciated. Thanks, Rob |
|
|
|
|
|
#2 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Winnipeg
Posts: 2,330
|
Quote:
=YEAR(B1)-YEAR(A1)+MIN(0,SIGN(MONTH(B1)-MONTH(A1)))&" years, "&MONTH(B1)-MONTH(A1)+MIN(0,SIGN(DAY(B1)-DAY(A1)))+MIN(0,SIGN(MONTH(B1)-MONTH(A1)))*-12&" months, "&IF(DAY(B1)-DAY(A1)<0,EOMONTH(A1,0)-A1+DAY(B1),DAY(B1)-DAY(A1))&" days" Regards,
__________________
Barrie Davidson "You're only given a little spark of madness. You mustn't lose it." - Robin Williams |
|
|
|
|
|
|
#3 | |
|
Board Regular
Join Date: Apr 2002
Location: Kissimmee, Florida
Posts: 384
|
Quote:
Rob, here are 2 ways to get years and months 1 text 1 formatting In both cases D8 contains the difference in cell dates. =INT(D8/365)&" Years, "&INT((D8-(365*INT(D8/365)))/30.25)&" Months" If you want exactly years and months put this formula in =TEXT(D8,"yy:mm") |
|
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Feb 2002
Location: Houston,Texas
Posts: 418
|
A simpler solution would be to custom format the cell.
yy" years",m" months" as a custom format will yield 08 years,3 months. yy:m will yield 8:3 |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|