Help

Re: Trying to use "if" and "date difference" together

774 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Lia_Garcia
4 - Data Explorer
4 - Data Explorer

Hi! My formula to flag an older blog post as in need of an update isn’t working and I’m not sure why. Here’s the formula:

IF(DATETIME_DIFF({Date Last Updated},TODAY(), ‘months’) > 12, “Update”, " ")

The logic I want is this:
If more than 12 months have elapsed between the date indicated in the {Date Last Updated} field and today, I would like the cell to say “Update.” Else, blank.

Can anyone advise?

2 Replies 2

Welcome to the community, @Lia_Garcia! :grinning_face_with_big_eyes: If the first date passed to DATETIME_DIFF() is older than the second one, the result will be a negative number, which means the comparison to see if that number is greater than 12 will never be true. This could be solved by either swapping the first two arguments:

IF(DATETIME_DIFF(TODAY(), {Date Last Updated}, 'months') > 12, "Update")

…or changing the comparison to look for a number less than -12:

IF(DATETIME_DIFF({Date Last Updated}, TODAY(), 'months') < -12, "Update")

In both of these, notice how I left off the empty string at the end. The final piece of an IF() function is optional; if omitted, it will automatically return the proper blank value based on the data type that the other portion returns.

Lia_Garcia
4 - Data Explorer
4 - Data Explorer

Worked like a charm! Thank you!