Trouble with DATETIME_DIFF when nested within an IF formula

Hey everyone,

Hoping somebody can help here.
I’m having trouble returning some info from a formula I have created.

I have a table to show the duration of certain tickets that are received for problems. I have a Date Raised field, Date Resolved field, and a Days Outstanding field.
I want the Days Outstanding to return the difference between Date Raised and Date Resolved when there is a value in the Date Resolved field, and I want it return the difference between Date Raised and TODAY() when the Date Resolved field is empty.

I’m currently using this formula:
IF({Date Resolved}!=BLANK(), DATETIME_DIFF({Date Resolved},{Date Raised}, ‘days’), DATETIME_DIFF(TODAY(),{Date Raised}, ‘days’))

Screenshot 2021-02-19 at 15.49.27

It’s working fine when Date Resolved is populated, but returns NaN when it’s empty.

I have created another field just to check that the today-date resolved formula works and it’s returning exactly what I want, it just doesn’t work when it’s inside the IF formula

can anybody explain this and show me a solution?

Thanks in advance!

Hey Alex, try taking out the !=BLANK() and just say IF({Date Resolved}, …

1 Like

Worked! Thanks my friend!

As a side note, this could also be simplified a little by putting the IF() function inside a single DATETIME_DIFF():

DATETIME_DIFF(IF({Date Resolved}, {Date Resolved}, TODAY()), {Date Raised}, 'days')

This topic was solved and automatically closed 3 days after the last reply. New replies are no longer allowed.