Calculating age from date of birth and ignoring if blank

  • Thread starter news.eternal-september.org
  • Start date
N

news.eternal-september.org

I've used the following formula to calculate a person's current age in years
based on a previously entered date of birth:

=ROUNDDOWN(YEARFRAC(P2, TODAY(), 1), 0)

However, if I haven't entered any data in the date of birth column, the
result cell shows the age "110", which throws out other calculations. Is
there any way to tell Excel not to enter any data if the date of birth is
blank?
Many thanks
 
G

Gord Dibben

Please do not multipost.

=IF(P2="","",(ROUNDDOWN(YEARFRAC(P2,TODAY(),1),0)))

Your formula is OK for just years but if you wanted a bit more precision the
undocumented DATEDIF function might be used.

See Chip Pearson's site for more on that.

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


Gord Dibben MS Excel MVP
 
C

Cimjet

Hi Gord
Strange, I replied only in Ms Public.Excel and it got posted in 3 different
area.
Maybe something new??
Regards
John
 
N

news.eternal-september.org

Thank you, that's exactly what I needed/

As you may have guessed, I'm fairly new to this!

"Cimjet" wrote in message
Hi
Try this : =IF(P2="","",ROUNDDOWN(YEARFRAC(P2, TODAY(), 1), 0))
HTH
John
 
C

Cimjet

You're welcome, glad I could help.
John
news.eternal-september.org said:
Thank you, that's exactly what I needed/

As you may have guessed, I'm fairly new to this!

"Cimjet" wrote in message
Hi
Try this : =IF(P2="","",ROUNDDOWN(YEARFRAC(P2, TODAY(), 1), 0))
HTH
John
 

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