PPRuNe Forums

PPRuNe Forums (https://www.pprune.org/)
-   Computer/Internet Issues & Troubleshooting (https://www.pprune.org/computer-internet-issues-troubleshooting-46/)
-   -   years & months in excel (https://www.pprune.org/computer-internet-issues-troubleshooting/401049-years-months-excel.html)

keyboard flier 6th January 2010 08:45

years & months in excel
 
Hi,
I am trying get an excel sheet to state an age in years and months but cannot do it.
I have a list of dates of birth and in the next column want to have the age in years and months in relation to todays date but all it will say is a the age to 1 decimal place, eg DOB 17/03/66 comes up with 43.8 years not 43 year 9 months.

Can somebody help, please.

Cacophonix 6th January 2010 09:20

KeyboardFlier

This formula works for me. Will calculate the difference between today's date and your birthday in cell A2.

=DATEDIF(A2,TODAY(),"y")&" years "&DATEDIF(A2,TODAY(),"ym")&" months "&DATEDIF(A2,TODAY(),"md")&" days"

MetoPower 6th January 2010 09:30

Enter date of birth in A1, the in A2 you may choose between:

=DATEDIF(A1,NOW(),"y")&"y,"&DATEDIF(A1,NOW(),"ym")&"m,"&DATE DIF(A1,NOW(),"md")&"d"

or

=DATEDIF(A1,TODAY(),"y")&" Years, "&DATEDIF(A1,TODAY(),"ym")&" Months and "&DATEDIF(A1,TODAY(),"md")&" Days"

You may replace "NOW" by "TODAY" or another date (or cell) and you may also remove the "days" bits.

MP

DeeJayEss 6th January 2010 11:26

Handy functions.

An alternative could be to keep the 43.8 number and have another cell that says something like '=LEFT(cell ref, 2) & " Years, " & (RIGHT(cell ref, 2) * 12) & " Months."'

The only issue you have here is that you cannot format the 'RIGHT(cell ref, 2) * 12' part of the code to specify a single decimal point. You could do it if you put the right(cell, 2) value into another cell and changed its format that way, or used VBA, which would be very neat and fast.

So for 43.8, the formula gives "43 Years, 9.6 Months."

I should specify this is native - there are some options out there (check this site for example) of addons for XL that can give you text and string formatting options without having to delve into the exciting world of XL VBA.

HTH, or at least gives you something else to think about. :eek:

keyboard flier 6th January 2010 11:40

Thank you all very much, works a treat now. :ok::ok::ok:


All times are GMT. The time now is 12:20.


Copyright © 2026 MH Sub I, LLC dba Internet Brands. All rights reserved. Use of this site indicates your consent to the Terms of Use.