View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.misc
Sandy Mann Sandy Mann is offline
external usenet poster
 
Posts: 2,345
Default Calculating age differences

Actually now that mu brian has started working again, I recall that the
problem I had was returning the age difference in time format but even that
seems to be working this morning:

=TEXT(TIME(DATEDIF(MIN(DATE(HOUR(C2),MINUTE(C2),1) ,DATE(HOUR(D2),MINUTE(D2),1)),MAX(DATE(HOUR(C2),MI NUTE(C2),1),DATE(HOUR(D2),MINUTE(D2),1)),"y"),DATE DIF(MIN(DATE(HOUR(C2),MINUTE(C2),1),DATE(HOUR(D2), MINUTE(D2),1)),MAX(DATE(HOUR(C2),MINUTE(C2),1),DAT E(HOUR(D2),MINUTE(D2),1)),"ym"),0),"hh:mm")&IF(DAT E(HOUR(C2),MINUTE(C2),1)<DATE(HOUR(D2),MINUTE(D2), 1),"
In advance"," Behind")

--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings


Replace @mailinator.com with @tiscali.co.uk


"Sandy Mann" wrote in message
...
"David Biddulph" <groups [at] biddulph.org.uk wrote in message
...
Of course if the OP wants to input the data in time format such as 10:01
in A2, then Excel can do the job of splitting it into your suggested
separate components, so the years in C2 would be =HOUR(A2), and the
months in D2 would be =MINUTE(A2).


Yes I tried that before I posted what I did but I thought that I was
finding errors with some times/Ageswhich I put down to the fact that with
Ages/times like 10:00 changing intoYears/Months because there is no month
zero. However, that said I find that it appears to be working this
morning. The forumula then becomes:

=DATEDIF(MIN(DATE(HOUR(C2),MINUTE(C2),1),DATE(HOUR (D2),MINUTE(D2),1)),MAX(DATE(HOUR(C2),MINUTE(C2),1 ),DATE(HOUR(D2),MINUTE(D2),1)),"y")&"
Year"&IF(DATEDIF(MIN(DATE(HOUR(C2),MINUTE(C2),1),D ATE(HOUR(D2),MINUTE(D2),1)),MAX(DATE(HOUR(C2),MINU TE(C2),1),DATE(HOUR(D2),MINUTE(D2),1)),"y")<1,"s
","
")&DATEDIF(MIN(DATE(HOUR(C2),MINUTE(C2),1),DATE(HO UR(D2),MINUTE(D2),1)),MAX(DATE(HOUR(C2),MINUTE(C2) ,1),DATE(HOUR(D2),MINUTE(D2),1)),"ym")&"
Month"&IF(DATEDIF(MIN(DATE(HOUR(C2),MINUTE(C2),1), DATE(HOUR(D2),MINUTE(D2),1)),MAX(DATE(HOUR(C2),MIN UTE(C2),1),DATE(HOUR(D2),MINUTE(D2),1)),"ym")<1," s
"," ")&IF(DATE(HOUR(D2),MINUTE(D2),1)DATE(HOUR(C2),MI NUTE(C2),1)," In
Advance"," Behind")

--
Regards,

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings


Replace @mailinator.com with @tiscali.co.uk