View Single Post
  #17   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Konczér, Tamás Konczér, Tamás is offline
external usenet poster
 
Posts: 9
Default Calculating age of death

On márc. 3, 18:43, joeu2004 wrote:
On Mar 3, 8:21 am, Ron Rosenfeld wrote:

On Thu, 3 Mar 2011 04:46:14 -0800 (PST), joeu2004 wrote:
=DATEDIF(B8,D8,"y")
+(D8=EDATE(B8,12+12*DATEDIF(B8,D8,"y")))

[....]
Since th OP also wanted months and days, Datedif
may be inappropriate.


Well, DATEDIF(...,"y") alone. *My bad: *I did not see the forest for
the trees. *I tend to look askance at responses to 3-year-old
questions in the first place.

But assuming that Tamas is interested in a year/month/day solution, I
would be inclined to use a helper cell, to wit:

X1:
=DATEDIF(B8,D8,"m")+(D8=EDATE(B8,1+DATEDIF(B8,D8," m")))

Then the year/month/day string can be constructed using:

=INT(X1/12) & " years, "
& X1-12*INT(X1/12) & " months, "
& D8-EDATE(B8,X1) & " days"

But for those that like one-liners:

=DATEDIF(B8,D8,"y")
+(D8=EDATE(B8,12+12*DATEDIF(B8,D8,"y")))
& " years, "
& MOD(DATEDIF(B8,D8,"m")
+(D8=EDATE(B8,1+DATEDIF(B8,D8,"m"))),12)
& " months, "
& D8-EDATE(B8,DATEDIF(B8,D8,"m"))
-(D8=EDATE(B8,1+DATEDIF(B8,D8,"m")))
& " days"

PS: *I am not aware of any defects with DATEDIF(...,"y") and
DATEDIF(...,"m") other than its dubious handling of leap dates. *But I
know that some people advocate not using DATEDIF at all (at least
starting with XL2007 SP2) because of the defect with
DATEDIF(...,"md"). *For consistency, they should also advocate not
using ROUND, INT and MOD, to name a few, because each has defects at
least in XL2003 and later.


Thank you. I was interested in the YMD like solution. (well,
erroneously I always write version 2007 however I got Off2010)