Google-sheets – How to use conditional formatting to choose between columns for a datedif function

conditional formattinggoogle sheets

I am trying to find the difference between two dates using this function =DATEDIF(G2,K2,"D"). I always want to find the difference between column K and either G or H depending on which one has a date. If a cell doesn't have a date it will have - in it.

How can I write an if function or filter to achieve this?

Best Answer

You might try:

=datedif(max(G4:H4),K4,"D")  

but may want to add some error trapping, in case K is less than G/H or they are both-.

I have absolutely no idea how or where Conditional formatting is involved in this.