DateDiff should be able to be negative

  • 6
  • Problem
  • Updated 2 months ago
I'm using the new DateDiff function in a Formula Field for the first time.

I expected that, if the DateDiff's "start date" was earlier than the "end date", that the result would be a positive number. And, if it were the reverse, it would be a negative number.

Instead, I'm finding that it's taking the number of days between the days, regardless of which is before the other. This isn't a blocker, since I can use Advanced Logic to combine it with a criteria for "End Date field is greater than Start Date field", but isn't intuitive to me. Maybe I'm just jaded from working with too many datediff functions in other contexts.

Here you can see the DateDiff function producing positive values regardless of which of the dates is earlier:

Photo of Seth

Seth, Champion

  • 12,062 Points 10k badge 2x thumb

Posted 2 months ago

  • 6
Photo of Scotty

Scotty

  • 1,204 Points 1k badge 2x thumb
We have datediff? Sweet!
Photo of Seth

Seth, Champion

  • 12,062 Points 10k badge 2x thumb
haha yessir!
Photo of Jitin Mehndiratta

Jitin Mehndiratta, Product Manager

  • 2,328 Points 2k badge 2x thumb
Hi Seth,

It was designed in this way to find out the number of days between two dates. But I agree that a +ive or -ive sign will help reduce an additional check to identify which date is prior. We plan to enhance the date diff function to be able to return the number of months, years also in addition to number of days. Timelines are not yet known. This change can be taken care of along with these enhancements.

Regards,
JitinĀ