Working out age of death using IF function

JLeMasonry

New Member
Joined
Jan 21, 2017
Messages
3
I am compiling a database featuring many different people. I need to be able to list their dates of birth, dates of death, and ages. So far, I have split these into three columns, E, F and G respectively, but I am having some trouble with the "Age" column. I need this column to do two things, if possible: if the person in question is alive, to list their current age at any given date, and if the person is dead, to list the age at which they died.

So far, my function for this column looks like this:

=IF([@DOD]>$B$1,DATEDIF([@DOB],$B$1,"y"),IF([@DOD]<$B$1,"Died"))

(B1 in this case is the specific date which will be changed accordingly.)

I feel like something needs to be added to the second IF function, to qualify that, if this function is true, the formula needs to work out the difference between DOD and DOB and display that as an age, but all my attempts to make this work have failed.

I appreciate that my formula is probably quite archaic and not altogether the most helpful formula in the world for this task, so any advice or suggestions would be appreciated!
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

Excel 2010
BCD
120-Jan-17
2
3DOBDODAGE
412-Dec-391-Feb-1575
55-May-6056
6
1e
Cell Formulas
RangeFormula
D4=IF(ISNUMBER(Table1[@DOD]),DATEDIF(Table1[@DOB],MIN(B1,Table1[@DOD]),"y"),DATEDIF(Table1[@DOB],$B$1,"Y"))
Named Ranges
NameRefers ToCells
DOB='1e'!$B$4:$B$5
DOD='1e'!$C$4:$C$5
Num={1,2,3,4,5,6,7,8,9,0}


N.B. The NUM named range does not apply to this question.
 
Last edited:
Upvote 0
Try also works.

=IF(ISBLANK(F2),DATEDIF(E2,B2,"Y"),DATEDIF(E2,F2,"Y"))
 
Upvote 0
Thank you so much, this has helped massively, and it's a much more finessed expression than the one I was previously dealing with. One more question, if I may: now that I am using the above formula pretty much word-for-word:

=IF(ISBLANK([@DOD]),DATEDIF([@DOB],$B$1,"Y"),DATEDIF([@DOB],[@DOD],"Y"))

Is there any way to have the Age column say "Died aged [Age at death]", rather than just a number? This is purely for aesthetic purposes, really, because the column now functions exactly as I need it to.

Thank you again!
 
Upvote 0
it'll be something on the line of > ="Died aged [DATEDIF([@DOB],[@DOD]]" i.e test for the death and then use that in the formula
 
Upvote 0
Try if this works,
=IF(ISBLANK([@DOD]),"Died at" & DATEDIF([@DOB],$B$1,"Y"),DATEDIF([@DOB],[@DOD],"Y"))
 
Upvote 0

Excel 2010
BCDEFG
120-Jan-17Key Date
2
3DOBDODAge
412-Dec-391-Feb-15Died at age75Died at age 75
55-May-60Key Date56
6
7T10_1701c1e
1e
Cell Formulas
RangeFormula
G4=IF(ISBLANK(C4),"",D4&" "&E4)
D4=IF(ISNUMBER(C4),"Died at age",$C$1)
D5=IF(ISNUMBER(C5),"Died at age",$C$1)
E4=DATEDIF(DOB,MIN($B$1,IF(C4="",$B$1,C4)),"y")
Named Ranges
NameRefers ToCells
DOB='1e'!$B$4:$B$5
Num={1,2,3,4,5,6,7,8,9,0}


You could hide columns D and E and unhide them if you need the information in those columns.
 
Last edited:
Upvote 0

Excel 2010
BCD
120-Jan-17Key date age
2
3DOBDOD
412-Dec-391-Feb-15Died at age 75
55-May-60Key date age 56
6
1e
Cell Formulas
RangeFormula
D4=IF(ISBLANK(C4),"Key date age"&" "&DATEDIF(DOB,MIN($B$1,IF(C4="",$B$1,C4)),"y"),"Died at age"&" "&DATEDIF(DOB,MIN($B$1,IF(C4="",$B$1,C4)),"y"))
Named Ranges
NameRefers ToCells
DOB='1e'!$B$4:$B$5



Excel 2010
BCDEFG
120-Jan-17Key date age
2
3DOBDODAge
412-Dec-391-Feb-15Died at age75Died at age 75Died at age 75
55-May-60Key date age56Key date age 56Key date age 56
6
1e
Cell Formulas
RangeFormula
D4=IF(ISNUMBER(C4),"Died at age",$C$1)
D5=IF(ISNUMBER(C5),"Died at age",$C$1)
E4=DATEDIF(DOB,MIN($B$1,IF(C4="",$B$1,C4)),"y")
E5=DATEDIF(DOB,MIN($B$1,IF(C5="",$B$1,C5)),"y")
F4=IF(ISBLANK(C4),D4&" "&E4,D4&" "&E4)
F5=IF(ISBLANK(C5),D5&" "&E5,D5&" "&E5)
G4=IF(ISBLANK(C4),"Key date age"&" "&DATEDIF(DOB,MIN($B$1,IF(C4="",$B$1,C4)),"y"),"Died at age"&" "&DATEDIF(DOB,MIN($B$1,IF(C4="",$B$1,C4)),"y"))
G5=IF(ISBLANK(C5),"Key date age"&" "&DATEDIF(DOB,MIN($B$1,IF(C5="",$B$1,C5)),"y"),"Died at age"&" "&DATEDIF(DOB,MIN($B$1,IF(C5="",$B$1,C5)),"y"))
Named Ranges
NameRefers ToCells
DOB='1e'!$B$4:$B$5


If you will never have to do calculations on your results,
delete the range D4:F4.
 
Last edited:
Upvote 0
Thank you everyone for your help. I have now amended the formula to read:

=IF(ISBLANK([@DOD]),DATEDIF([@DOB],$B$1,"Y"),"Died age"&" "&DATEDIF([@DOB],[@DOD],"Y"))

And this has fixed all the issues I had for this query. The formula will now return, if the person is dead, at what age they died (i.e., "Died age 76"), or, if they are alive, their current age.

Thank you all so much for your help!
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top