ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   If statements (https://www.excelbanter.com/excel-worksheet-functions/44074-if-statements.html)

cassandra

If statements
 

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


--
cassandra
------------------------------------------------------------------------
cassandra's Profile: http://www.excelforum.com/member.php...o&userid=27026
View this thread: http://www.excelforum.com/showthread...hreadid=438908


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


"cassandra" wrote
in message ...

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


--
cassandra
------------------------------------------------------------------------
cassandra's Profile:
http://www.excelforum.com/member.php...o&userid=27026
View this thread: http://www.excelforum.com/showthread...hreadid=438908




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

Replace@mailinator with @tiscali.co.uk


"cassandra" wrote
in message ...

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


--
cassandra
------------------------------------------------------------------------
cassandra's Profile:
http://www.excelforum.com/member.php...o&userid=27026
View this thread: http://www.excelforum.com/showthread...hreadid=438908





cassandra


Thanks for the help. I know there was a way to do it right.


--
cassandra
------------------------------------------------------------------------
cassandra's Profile: http://www.excelforum.com/member.php...o&userid=27026
View this thread: http://www.excelforum.com/showthread...hreadid=438908


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 ;-)


"cassandra" wrote
in message ...

Thanks for the help. I know there was a way to do it right.


--
cassandra
------------------------------------------------------------------------
cassandra's Profile:
http://www.excelforum.com/member.php...o&userid=27026
View this thread: http://www.excelforum.com/showthread...hreadid=438908





All times are GMT +1. The time now is 07:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com