Formula to compute someone's age if you enter their B-day

M

Millerk

I'm trying to find out the formula that will allow someone to enter a child's
birthday in one cell and another cell will compute their age.
 
G

Gary''s Student

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


if the birthday is in A1
 
J

John K

You can put today() in any cell ie a1 then put the date you want ie
02/17/1989 in say a2. Then in b2 put =year(a1)-year(a2). This will give you
the age. Be sure to make b2 or the cell the formulars in a number format.

John
 
M

Millerk

First, thank you very much for the formula.

Second, how can I set up a condition formula using this formula so that the
cell will be yellow 5 days prior to their birthday and red up to 5 days after
their birthday.
 
M

Millerk

I used the following formula to compute the DOB in order to not have to use
multiple cells.

=DATEDIF(C5,NOW(),"y") where C5 has DOB and formula is in D5

The problem with this is that if nothing is entered in C5 then it gives me a
solution of 106 instead of leaving it blank. What am I doing wrong here?
 
B

Bill (Unique as my name)

Why wouldn't =(NOW()-A1)/365 work. It does not account
for leap years, but how accurate do you need to be?
 
P

Pete_UK

Dates are stored in Excel as the number of days elapsed since some
reference date - the date is 31st December 1899. So, if C5 is empty,
there are 106 years between the reference date and today. To guard
against this you could have something like:

=IF(C5=0,0,DATEDIF(C5,NOW(),"y"))

Hope this helps.

Pete
 
M

Millerk

Pete,

Thanks for the formula. I fooled around with it after I posted the question
and came up with a very similar formula that seems to be working.

=IF(C5="","",DATEDIF(C5,NOW(),"y"))

I guess the ""= 0 in this case. Thanks for the response.
 
Top