-
Type: Bug
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: 6.0.5, 7.0.12
-
Component/s: None
-
None
-
Server Triage
-
ALL
-
The $dateDiff expression fails to return accurate differences for date ranges that are close together, particularly when the dates differ by small increments such as seconds. According to MongoDB's documentation, $dateDiff should return the integer difference between startDate and endDate measured in the specified units. But then it also says, "Durations are measured by counting the number of times a unit boundary is passed", which seems to contradict the first explanation and can be confusing.
I get that you might see this as a feature rather than a bug. If that's the case, it would be really helpful to document it more clearly and include some examples. Right now, the behavior isn't obvious, and it can lead to misunderstandings.
Here's a mongo playground link with some examples.