Forum Discussion

Bezz8's avatar
Bezz8
Copper Contributor
Jun 26, 2021
Solved

Data consolidation to compute duration in years between to different format of Dates.

Hello everyone,    I am trying to calculate the period of time between dates that have been set with different formats (some times year only, other month-year, others the extended date). For sake o...
  • HansVogelaar's avatar
    Jun 26, 2021

    Bezz8 

    Let's say your data are in columns A and B.

    In C2, enter the formula =IF(LEFT(CELL("format",A2))="D",A2,DATE(A2,1,1))

    This will replace a year with January 1 of that year. As an alternative, you might use July 1 - the middle of the year, as best guess of the date: =IF(LEFT(CELL("format",A2))="D",A2,DATE(A2,7,1))

    Fill to the right to D2.

    In E2, enter the formula =IFERROR(DATEDIF(C2,D2,"Y"),"---")

    Select C2:E2, and fill down to the end of the data.

     

Resources