Forum Discussion

PWWRB's avatar
PWWRB
Copper Contributor
Oct 13, 2022

Yearfrac stopping dates in future

Want to use yearfrac instead of datedif and it works but we want to have it give a value of 0 if one of the dates is in the future.  I want to figure out how long someone has worked for us based on t...
  • HansVogelaar's avatar
    Oct 13, 2022

    PWWRB 

    Let's say you have dates in D2 and E2.

    =IF(OR(D2:E2>TODAY()),0,YEARFRAC(D2,E2))

    This can be filled down.

    If you want to compare D2 to today's date:

    =IF(D2>TODAY(),0,YEARFRAC(D2,TODAY()))

Resources