user8876747
user8876747

Reputation: 35

IF statement to calculate days between dates if column contains date

I have two columns, Last Upload and Final Date. I have a formula to calculate the difference between today and the Last Upload using

=DATEDIF( [@[Last Upload]],TODAY(),"d")

However, sometimes the Last Upload column will be blank and in this case we would like to use the Final Date column instead.

Is there a way to combine and use the above statement when the column is not blank and the other when it is? I have been trying to nest it with an IF statement but struggling to do so.

Upvotes: 2

Views: 434

Answers (2)

Justyna MK
Justyna MK

Reputation: 3563

Alternative solution:

=DATEDIF(IF(LEN([@[Last Upload]]),[@[Last Upload]],[@[Final Date]]),TODAY(),"d")

LEN might be a little bit more error-proof than ISBLANK.

Upvotes: 0

EylM
EylM

Reputation: 6103

You could use ISBLANK formula combined with IF formula.

=DATEDIF(IF(ISBLANK([@[Last Upload]]),[@[Final Date Upload]],[@[Last Upload]]),TODAY(),"d")

Upvotes: 1

Related Questions