<!-- llms-explorer concept facts · https://llms-explorer.com/tree/pre-epoch-date-arithmetic-upgrade-compatibility/ · pack 2026-10-29 · ~1120 tokens -->

# Pre-epoch date arithmetic upgrade compatibility

> Source-anchored research for Pre-epoch date arithmetic upgrade compatibility. Run status: COMPLETED.

Parent: [MongoDB Aggregation Pipeline](https://llms-explorer.com/tree/mongodb-aggregation-pipeline/) · 4 facets · 10 facts · page: https://llms-explorer.com/tree/pre-epoch-date-arithmetic-upgrade-compatibility/

## Structure and components

- The inspected MongoDB unit tests include pre-epoch date-part extraction in UTC and America/New_York and DateAdd tests for positive and negative second and millisecond amounts. Those tests are useful fixture patterns, but do not by themselves prove cross-version 8.3 compatibility. (low confidence) (verified as of 2026-10-27) — [source](https://raw.githubusercontent.com/mongodb/mongo/master/src/mongo/db/query/datetime/date_time_support_test.cpp)

## How it works

- MongoDB documents that, starting in 8.3, $dateAdd and $dateSubtract return a result one second greater than previous versions when the input precedes 1970-01-01T00:00:00Z and unit is not millisecond. This describes a timestamp difference, not an execution-time increase. (high confidence) (verified as of 2026-10-27) — [source](https://www.mongodb.com/docs/manual/release-notes/8.3.md)

## Problems, failure modes and limitations

- The release notes explicitly extend the compatibility warning to aggregations performing time-based calculations, including $setWindowFields and $densify. They do not say every output document or accumulator changes by exactly one second. (high confidence) (verified as of 2026-10-27) — [source](https://www.mongodb.com/docs/manual/release-notes/8.3.md)
- Alibaba Cloud lists the same pre-epoch/non-millisecond condition but describes results as one second slower. MongoDB and Percona describe a timestamp that is one second greater; the Alibaba wording alone cannot substantiate a query-latency regression. (medium confidence) (verified as of 2026-09-10) — [source](https://www.alibabacloud.com/help/en/mongodb/product-overview/features-of-mongodb-8-3)

## Facts and statements

- The documented pre-epoch compatibility condition excludes millisecond units and inputs at or after the UTC epoch; it does not establish a general one-second shift for every date expression. (high confidence) (verified as of 2026-10-27) — [source](https://www.mongodb.com/docs/manual/release-notes/8.3.md)
- Do not assume replacing calendar units with fixed millisecond durations preserves semantics: $dateAdd uses the selected timezone for calculation, applies daylight-saving offsets, and adjusts month-or-larger additions at month ends. The implementation gives millisecond addition a separate direct-duration path. (medium confidence) — [source](https://www.mongodb.com/docs/v8.3/reference/operator/aggregation/dateadd/)
- The inspected MongoDB master implementation floors negative fractional seconds in seconds(Date_t) and handles TimeUnit::millisecond by direct addition. These implementation details help select regression inputs; an unpinned master snapshot does not identify the commit responsible for the 8.3 compatibility change. (low confidence) (verified as of 2026-10-27) — [source](https://raw.githubusercontent.com/mongodb/mongo/master/src/mongo/db/query/datetime/date_time_support.cpp)
- Do not automatically replace day, month, or year arithmetic with fixed millisecond counts: both operators apply timezone rules, including DST where applicable, and adjust month-or-larger arithmetic to the last valid day of the month. (high confidence) — [source](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateAdd/)
- In the reviewed master implementation, dateAdd returns date + Milliseconds(amount) immediately for the millisecond unit; other units pass through timezone/timelib processing. This supports separate millisecond controls but does not prove the implementation of a particular 8.3 patch. (low confidence) (verified as of 2026-10-27) — [source](https://raw.githubusercontent.com/mongodb/mongo/master/src/mongo/db/query/datetime/date_time_support.cpp)
- The reviewed upstream test file includes dateAdd tests for DST transitions, fixed-offset timezones, seconds, milliseconds, and overflow. These are useful test dimensions, but they do not constitute a before/after upgrade execution result. (low confidence) (verified as of 2026-10-27) — [source](https://raw.githubusercontent.com/mongodb/mongo/master/src/mongo/db/query/datetime/date_time_support_test.cpp)
