-
Type: Improvement
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Aggregation Framework
-
None
-
Fully Compatible
Currently we treat numbers added or subtracted to dates as whole days (24*60*60*1000 millis). I think we should treat them as milliseconds instead. This way adding 30 minutes looks like {$add:['$date', 30*60*1000]} rather than {$add:['$date', 30.0/24/60]} or {$add:['$date', 1.0/24/2]}
Also currently subtracting two dates yields a Date-typed result when the result should probably be a NumberLong of the number of milliseconds between the dates. Currently it would return a result around 1970-01-01 for dates that are near each other.
Expected results
Date - Date : NumberLong(Milliseconds between times)
Num - Date : Error
Date - Num : Date(original - Num as milliseconds)
Date + Date : Error (current behavior)
Num + Date : Date(with num treated as millis)
Date + Num : Same as above.
- is depended on by
-
SERVER-6196 'can't add two dates together' assertion during constant folding
- Closed
- is duplicated by
-
SERVER-6547 $subtract in aggregation framwork with 2 dates should give number of milliseconds between them
- Closed
-
SERVER-12043 $unixDays, $unixYears, $unixHours like operator for Date Aggregation Operators
- Closed
- is related to
-
SERVER-6240 Disable math with Dates in agg
- Closed