YEARFRAC won't turn negative

Copper Contributor

Hi there, 

 

I am wanting the yearfrac formula to turn negative if the 2nd date is before the 1st date. So in the below example it would be -.083 instead of just giving me the difference. Is there a way to do this?

2 Replies

@liz123395 

=IF(A1<B1,YEARFRAC(A1,B1),-YEARFRAC(A1,B1))

 

Would this formula be acceptable? It returns the intended result in my sheet.

@liz123395 

As variant

=SIGN(B1-A1)*YEARFRAC(A1,B1)