Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert Birthday from MM/DD/YY to Age 2

Status
Not open for further replies.

JockVSJock

Technical User
Jun 28, 2001
59
US


Doing a report for my boss and right now we are showing the
age of a person like this:

8/17/73

My boss informed me legally we can't do this, it has to be in a format like this:

3005

30 means the person is 30 years old and 5 months.

Is there anyway in Excel to create some sort of formual that will convert from 8/17/73 to 3005?

thanks

 
There is a datedif function in Excel that should enable you to get the formula you need. An example:

in cell A1, you input the birthday.
in cell B1, you can calculate the number of years first by datedif(A1,Now(),"Y")
in cell C1, you can calculate the number of months using datedif(A1,Now(),"YM").
in cell D1, you concatenate the results from B1 and C1.

This is just a simplified example but it should give you an idea of how to best accomplish what you need.

-----------------------------------------------------------------------------------------------------
"If you can't explain something to a six-year-old, you really don't understand it yourself."
-- Albert Einstein
 
To understand more about the DATEDIF() function, take a look at the below FAQ, and look for the DATEDIF() syntax and examples:

faq68-4037 - What are some of Excel's date functions?

I would use Chopsick's solution, but I would put it all into one formula instead of using 3 cells:

=DATEDIF(A1,NOW(),"Y")&IF(LEN(DATEDIF(A1,NOW(),"YM")=2),"0"&DATEDIF(A1,NOW(),"YM"),DATEDIF(A1,NOW(),"YM"))

Will get you what you need! ;-)





Peace!! [peace]

Mike

Didn't get the answers that you wanted? Take a look at FAQ219-2884
 
Bowers74,

Chopsick? [rofl2]

Much more elegant solution! A star for you! And I'll have to remember to look in the FAQ section more often... Thanks for the assist.

-----------------------------------------------------------------------------------------------------
"If you can't explain something to a six-year-old, you really don't understand it yourself."
-- Albert Einstein
 
Thanks for the
star.gif
!

I'm glad I could help!



Peace!! [peace]

Mike

Didn't get the answers that you wanted? Take a look at FAQ219-2884
 

Rather than checking the length of the "YM" element (and invoking the function twice), I would do this ..

Code:
=DATEDIF(A1,NOW(),"Y")&RIGHT("0" & DATEDIF(A1,NOW(),"YM"),2)

Enjoy,
Tony

------------------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading FAQ222-2244 before you ask a question.
 
Tony - KUDOS for the logic!

Have a
star.gif
from me, because I would have never though of that! ;-)



Peace!! [peace]

Mike

Didn't get the answers that you wanted? Take a look at FAQ219-2884
 
Thanks, Mike,

It's something I do quite a lot to pad values with zeroes .. and every little bit helps with performance [smile]

Enjoy,
Tony

------------------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading FAQ222-2244 before you ask a question.
 


Thanks everyone for your help.

All of your answers are right on target!!!

THANKS!!!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top