[SERVER-6239] Better semantics for $add and $subtract with Dates Created: 28/Jun/12 Updated: 28/Oct/15 Resolved: 17/Dec/12 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Aggregation Framework |
| Affects Version/s: | None |
| Fix Version/s: | 2.3.2 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Mathias Stearn | Assignee: | Mathias Stearn |
| Resolution: | Done | Votes: | 18 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||||||
| Description |
|
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) Date + Date : Error (current behavior) |
| Comments |
| Comment by auto [ 15/Dec/12 ] |
|
Author: {u'date': u'2012-12-14T23:10:44Z', u'email': u'mathias@10gen.com', u'name': u'Mathias Stearn'}Message: Date - Date : NumberLong(Milliseconds between times) Date + Date : Error |
| Comment by Arseny Tolmachev [ 09/Dec/12 ] |
|
This would be a very very useful feature. |
| Comment by Paul Grinchenko [ 06/Dec/12 ] |
|
We would love to have this feature. |