# Age Calculation

K

#### kjstec

I know how to calculate ages such as =YEAR(P327)-YEAR(D327). However, here
is my problem:

I have four columns:
One is the date of birth of the patient
Another is date patient screeded
The next is date patient randomized
The last is age at randomization

Not all patients get randomized. All patients must be screened, but I only
want the age shown if the patient was randomized. If I copy the formula down
the column, it also grabs the blank field in the randomized column and
returns a erroneous age. How can I fix this so that if a randomized field is
blank, the age at randomization cell will also be blank?

Any help is greatly appreciated.

Thanks,
Kathy

R

#### ruic

you need to use an IF statement:

If randomized cell isblank then do nothing else calculate age.

isblank is an actuall excel function also.

I'll leave the details to you.

E

#### Eduardo

Hi,
you can use an if Statement, suppose that the date patient randomized is in
column C

=if(C237="","",(YEAR(P327)-YEAR(D327)), this will leave the cell blank if
C237 is blank

E

#### egun

You simply wrap your formula in an IF statement:

=IF(C327="","",YEAR(P327)-YEAR(D327))

assuming C327 holds the randomization cell. If C327 is blank, then the age
cell is left blank also.

For trivia's sake, this formula will calculate age to the nearest day:

=IF(DATEDIF(\$A2,NOW(),"y")<10," ","") & DATEDIF(\$A2,NOW(),"y") & " years, "
& IF(DATEDIF(\$A2,NOW(),"ym")<10," ","") & DATEDIF(\$A2,NOW(),"ym") & " months,
" & IF(DATEDIF(\$A2,NOW(),"md")<10," ","") & DATEDIF(\$A2,NOW(),"md") & " days"

HTH,

Eric