Dates.. dates... how about this formulas ??
Posted by Juan Pablo on November 16, 2001 12:16 PM
I'm not happy when a formula doesn't work the way it should do, so i'm proposing this one so you can tell me if it works a little better, and we can end the "saga" ... (Start in B1, end in C1)
Juan Pablo
For years:
=IF(AND(MONTH(C1)>=MONTH(B1),DAY(C1)>=DAY(B1)),YEAR(C1)-YEAR(B1),IF(AND(MONTH(C1)>MONTH(B1),DAY(C1)<DAY(B1)),YEAR(C1)-YEAR(B1),YEAR(C1)-YEAR(B1)-1))
For months:
=IF(AND(MONTH(C1)>=MONTH(B1),DAY(C1)>=DAY(B1)),MONTH(C1)-MONTH(DATE(YEAR(C1),MONTH(B1),DAY(B1))),IF(AND(MONTH(C1)>MONTH(B1),DAY(C1)<DAY(B1)),MONTH(C1)-MONTH(DATE(YEAR(C1),MONTH(B1),DAY(B1)))-1,IF(AND(MONTH(C1)<MONTH(B1),DAY(C1)>=DAY(B1)),12-MONTH(B1)+MONTH(C1),12-MONTH(B1)+MONTH(C1)-1)))
For days:
=IF(DAY(C1)>=DAY(B1),DAY(C1)-DAY(B1),DAY(C1)+DATE(YEAR(C1),MONTH(C1),1)-1-DATE(YEAR(C1),MONTH(C1)-1,DAY(B1)))
It involves the use of the Date() function, maybe that helps.
Juan Pablo