View Single Post
  #35   Report Post  
Grizzly Bear
 
Posts: n/a
Default


Hey all...

I thought I might tackle the year - month - day problem, but I have a
few questions first.

From the previous posts I concluded that a full month equals both of
the following:

An end date that is the same day of the month as the start date
ex. 15 Jan 2005 & 15 Feb 2005 should be 0-1-0

An end date that is the end of the month
ex. 28 Feb 2005 counts as a full month presuming that the start date is
prior to Feb.

This brings up a problematic question....

If the start month has more days than the end month AND the end date is
the last day of the month while the start date is not eom but still =
the end date.....

Ex:
Start: 28 Jan 2005
END: 28 Feb 2005
Should the result be 0-1-0 or 0-1-3? ( the 28th to the 28th is 1 month
so what about the 3 days left in Jan?)

It get even weirder as you progress the dates:
28 Jan 2005 to 27 Feb 2005 = 0-0-30 (3 days in Jan + 27 in Feb)

28 Jan 2005 to 28 Feb 2005 = 0-1-0 ? or 0-1-3 (3 days left in Jan +
Feb, yet the 28th to the 28th should be a month) but how can you go
from 0-0-30 to 0-1-3 by changing just one day?

28 Jan 2005 to 01 Mar 2005 = 0-1-1 ? or 0-1-4 (3 days left in Jan + Feb
+ 1 day March yet 1-28 to 2-28=1 month +1 day for March))

29 Jan 2005 to 01 Mar 2005 = 0-1-3 (2 days left in Jan + Feb + 1 day
March)

30 Jan 2005 to 01 Mar 2005 = 0-1-2 (1 day left in Jan + Feb + 1 day
March)

Anyway, notwithstanding clarification on this problem, here is my
solution:

=IF(MONTH(B1)<MONTH(A1),YEAR(B1)-YEAR(A1)-1,YEAR(B1)-YEAR(A1))&" Years
"&
IF(MONTH(A1)MONTH(B1),IF(DAY(B1)=DAY(EOMONTH(B1,0 )),MONTH(B1)-MONTH(A1)+12,MONTH(B1)-MONTH(A1)+11),IF(DAY(B1)=DAY(EOMONTH(B1,0)),MONTH( B1)-MONTH(A1),IF(DAY(B1)DAY(A1),MONTH(B1)-MONTH(A1),MONTH(B1)-MONTH(A1)-1)))&"
Months "&
IF(DAY(B1)=DAY(EOMONTH(B1,0)),DAY(EOMONTH(A1,0))-DAY(A1),IF(DAY(B1)<DAY(A1),DAY(EOMONTH(A1,0))-DAY(A1)+DAY(B1),DAY(B1)-DAY(A1)))&"
Days"

GrizzlyBear


--
Grizzly Bear


------------------------------------------------------------------------
Grizzly Bear's Profile: http://www.excelforum.com/member.php...fo&userid=1838
View this thread: http://www.excelforum.com/showthread...hreadid=372455