Forum Discussion

DeannaG45's avatar
DeannaG45
Copper Contributor
Dec 18, 2022

Cell to calculate Age based on Text in Adjacent cell

B2 is Start Date

C2 is End Date

D2 is text drop down Years, Months, Days

E2 I need a formula to calculate a value between Start and End Dates 

    in years if text in D2="Years" OR

    in months if text in D2="Months" OR

    in days if text in D2="Days"

  • Harun24HR's avatar
    Harun24HR
    Bronze Contributor

    DeannaG45 Use IFS() and DATEDIF() function.

     

    =IFS(D2="Years",DATEDIF(B2,C2,"Y"),D2="Months",DATEDIF(B2,C2,"YM"),D2="Days",DATEDIF(B2,C2,"MD"))

     

    If want to calculate fraction values-

    =IFS(D2="Years",(C2-B2)/365,D2="Months",(C2-B2)/30,D2="Days",C2-B2)

     

    • DeannaG45's avatar
      DeannaG45
      Copper Contributor

      Harun24HR thank you so much for your reply!!! I’m out away from the file, but I will get back to you once I can to let you know my excitement!!!

       

      Cheers!

Resources