
OPERATIONAL DEFECT DATABASE
...

...
Example expression: {$dateAdd: { startDate: ISODate("2021-01-01T00:00:00.002Z"), amount: 3, unit: 'millisecond', }} The startDate is 2 milliseconds after midnight, so I'd expect the result to be 5 milliseconds after midnight. Instead it's 3 milliseconds after midnight: the startDate's milliseconds are truncated before doing the addition. It looks like we are truncating here because a timelib helper doesn't accept milliseconds: https://github.com/mongodb/mongo/blob/1eadaf115d098198845026aef15b0f24578b46b8/src/mongo/db/query/datetime/date_time_support.cpp#L1136 But the timelib struct does have a microseconds field we can populate: https://github.com/mongodb/mongo/blob/1eadaf115d098198845026aef15b0f24578b46b8/src/third_party/timelib-2021.04/timelib.h#L248
xgen-internal-githook commented on Fri, 14 May 2021 09:06:13 +0000: Author: {'name': 'Denis Grebennicov', 'email': 'denis.grebennicov@mongodb.com', 'username': 'denis631'} Message: SERVER-56221 $dateAdd ignores startDate milliseconds Branch: master https://github.com/mongodb/mongo/commit/11f57fd3779713de3e2e3b6a2ab3769c3ef95e65
Click on a version to see all relevant bugs
MongoDB Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.