Convert days into Years/Months/Days

FryGirl

Well-known Member
Joined
Nov 11, 2008
Messages
1,368
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have two dates subtracted which gives yields 867

How to convert to ? Yrs ? Mths ? Days
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Something like this...
=IF(DATEDIF(A1,B1,"y")=0,"",DATEDIF(A1,B1,"y")&" years ")&IF(DATEDIF(A1,B1,"ym")=0,"",DATEDIF(A1,B1,"ym")&" months ")&DATEDIF(A1,B1,"md")&" days"
 
Upvote 0
Another option would be to subtract the dates and use custom formatting.

Format as

[TABLE="width: 273"]
<colgroup><col width="273"></colgroup>[TR]
[TD="width: 273"]yy "years" mm "months" dd "days"[/TD]
[/TR]
[/TABLE]
Excel Workbook
ABC
15/17/20159/30/201702 years 05 months 16 days
Sheet
 
Upvote 0
Another option would be to subtract the dates and use custom formatting.

Format as

[TABLE="width: 273"]
<tbody>[TR]
[TD="width: 273"]yy "years" mm "months" dd "days"[/TD]
[/TR]
</tbody>[/TABLE]
Which, of course, means you can do it easily by formula as well if desired...

=TEXT(B1-A1,"yy"" years ""mm"" months ""dd"" days""")
 
Last edited:
Upvote 0
Another option would be to subtract the dates and use custom formatting.

Format as

[TABLE="width: 273"]
<tbody>[TR]
[TD="width: 273"]yy "years" mm "months" dd "days"[/TD]
[/TR]
</tbody>[/TABLE]

ABC

<colgroup><col style="width:30px; "><col style="width:76px;"><col style="width:76px;"><col style="width:203px;"></colgroup><tbody>
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]1[/TD]
[TD="align: right"]5/17/2015[/TD]
[TD="align: right"]9/30/2017[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=ffff00]#ffff00[/URL] , align: right"]02 years 05 months 16 days[/TD]

</tbody>

Spreadsheet Formulas
CellFormula
C1=B1-A1

<tbody>
</tbody>

<tbody>
</tbody>


Excel tables to the web >> Excel Jeanie HTML 4

This does not return the correct result because it returns the date (year/month/day) calculated from 1 Jan 1900 plus 867 days.
It returns 2 (year 1902,), 5 (May), 16 (day).

The correct answer should be 2 years, 4 months, 13 days
 
Upvote 0
This does not return the correct result because it returns the date (year/month/day) calculated from 1 Jan 1900 plus 867 days.
It returns 2 (year 1902,), 5 (May), 16 (day).

The correct answer should be 2 years, 4 months, 13 days

Darn, I should have checked better :(
[Table="width:, class:grid"][tr][td] [/td][td]
A​
[/td][td]
B​
[/td][td]
C​
[/td][td]
D​
[/td][/tr]
[tr][td]
1​
[/td][td]
5/17/2015​
[/td][td]
9/30/2017​
[/td][td]
02 years 05 months 16 days​
[/td][td]2 years 4 months 13 days[/td][/tr]

[tr][td]
2​
[/td][td][/td][td][/td][td]Formatted[/td][td]calc'd[/td][/tr]
[/table]


That also means Rick's suggestion doesn't work, either :(
 
Last edited:
Upvote 0
footoo - Good catch. Like Ford I should have done the math.
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,315
Members
452,634
Latest member
cpostell

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top