Welcome to the Airtable Community! If you're new here, check out our Getting Started area to get the most out of your community experience.

# Trouble with DATETIME_DIFF when nested within an IF formula

Topic Labels: Formulas
Solved
338 3
cancel
Showing results for
Did you mean:
5 - Automation Enthusiast

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’))

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?

1 Solution

Accepted Solutions
10 - Mercury

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

3 Replies 3
10 - Mercury

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

5 - Automation Enthusiast

Worked! Thanks my friend!

18 - Pluto

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')
``````