DateDiff should be able to be negative

  • 6
  • Idea
  • Updated 2 weeks ago
  • Under Consideration
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, Employee

  • 14,400 Points 10k badge 2x thumb

Posted 5 months ago

  • 6
Photo of Scotty

Scotty, Champion

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

Seth, Employee

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

Jitin Mehndiratta, Product Manager

  • 3,110 Points 3k 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.

Photo of Sai Ram Pulluri

Sai Ram Pulluri, Official Rep

  • 11,818 Points 10k badge 2x thumb
Hi Seth, 

Since this is working as expected changing this to an enhancement request.This is a valid use-case and we have added this to our road-map.

Thanks for posting.