If statements

C

cassandra

I have if statement to get the current age. but if there is DOB is
blank the current age is 105.

DOB is D4 and the if statement is in Current age D5

=IF(MONTH(TODAY())>MONTH(D4),YEAR(TODAY())-YEAR(D4),
IF(AND(MONTH(TODAY())=MONTH(D4),DAY(TODAY())>=DAY(D4)),
YEAR(TODAY())-YEAR(D4),(YEAR(TODAY())-YEAR(D4))-1))



What if statment should i use to get Current age to be blank until
there is a date entered in the DOB.


Thanks
 
T

Trevor Shuttleworth

Cassandra

=IF(D4="","",
IF(MONTH(TODAY())>MONTH(D4),YEAR(TODAY())-YEAR(D4),
IF(AND(MONTH(TODAY())=MONTH(D4),DAY(TODAY())>=DAY(D4)),
YEAR(TODAY())-YEAR(D4),(YEAR(TODAY())-YEAR(D4))-1))
)

Regards

Trevor
 
S

Sandy Mann

Trevor gave you the answer for your formula but you could also use the
DATEDIF function:

=If (D1="","",DATEDIF(D1,TODAY(),"y"))

The DATEDIF function is only explained in XL 2000 Help but Chip Pearson has
a page on his Website about it:

http://www.cpearson.com/excel/datedif.htm

--
HTH

Sandy
(e-mail address removed)
Replace@mailinator with @tiscali.co.uk
 
T

Trevor Shuttleworth

You're welcome. There's often a variety of ways to "do it right" as in this
case ... it's just finding them ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top