date difference in day,month & years

JIGYANSHA1985
StarLounger
Posts: 77
Joined: 15 Jan 2011, 02:32

date difference in day,month & years

Post by JIGYANSHA1985 »

Sir,
In an excel sheet 5 fields are there ... What I would like to do is to subtract two dates i.e. DOA - DOB. And the the answer should come like as mentioned below in column E, D & C.
A B C D E
========================================
DOB DOA YY MM DAY
========================================
02/03/1981 02/02/2011 29 11 0

Earlier I am trying to use the below method but that does not serve my purpose ...
c2: =YEAR(B2)-YEAR(A2)
d2: =IF(MONTH(B2)>MONTH(A2),MONTH(B2)-MONTH(A2),MONTH(B2)+SUM(12-MONTH(A2)))
e2: =IF(DAY(B2)>DAY(A2),DAY(B2)-DAY(A2),1+DAY(A2))

but by doing it the answers comes like this yy=30, mm=11, and day=3. So almost 1 year difference comes.

Would you pl. help me solving this problem in your way ...

User avatar
HansV
Administrator
Posts: 78500
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: date difference in day,month & years

Post by HansV »

In C2: =DATEDIF(A2,B2,"Y")
In D2: =DATEDIF(A2,B2,"YM")
In E2: =DATEDIF(A2,B2,"MD")

See DATEDIF Worksheet Function.
Best wishes,
Hans

JIGYANSHA1985
StarLounger
Posts: 77
Joined: 15 Jan 2011, 02:32

Re: date difference in day,month & years

Post by JIGYANSHA1985 »

Thanks, Sir for this reply .. But, in case of a leap year whether any difference shall found or not in Age calculation.

User avatar
HansV
Administrator
Posts: 78500
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: date difference in day,month & years

Post by HansV »

The DATEDIF function takes leap years into account.
Best wishes,
Hans

JIGYANSHA1985
StarLounger
Posts: 77
Joined: 15 Jan 2011, 02:32

Re: date difference in day,month & years

Post by JIGYANSHA1985 »

Allright Sir... Thanks for clearing the concept & removing my doubts...