[DOCS-10610] Docs for SERVER-6310: Timezone support in date operators at query time Created: 31/Jul/17 Updated: 29/Oct/23 Resolved: 21/Sep/17 |
|
| Status: | Closed |
| Project: | Documentation |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 3.5.11 |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Emily Hall | Assignee: | Ravind Kumar (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | aggregation, expression, timezone, usability | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||
| Days since reply: | 6 years, 21 weeks ago | ||||||||||||||||||||||||
| Epic Link: | DOCS: 3.6 Server | ||||||||||||||||||||||||
| Description |
Documentation Request Summary:Design document can be found through https://docs.google.com/document/d/1I_x4NNWgfcXzmEFTPTYZkjIQVq_JUnZcxb5ak0o52oU/edit#heading=h.1rcba4503t2j Engineering Ticket Description:Issue Status as of July 26, 2017 ISSUE SUMMARY In previous versions of MongoDB, the date extraction operations $year, $month, etc. could only extract the information from Date types in the UTC time zone. This meant that In versions 3.5.11 and newer, MongoDB still does not have a concept of a server-wide time zone, but the date extraction operators ($year, $month, $day, $hour, $minute, $second, $millisecond, $isoYear, $isoWeekYear and {{$isoDayOfWeek} allow for a secondary format to specify a time zone to express a local time. USER IMPACT This is not a BC breaking change. The original syntax of the operators is still functional:
A new syntax is now also supported, to allow for the extra timezone field:
TECHNICAL DETAILS The implementation of time zone support is done through "timelib". Several formats for the timezone field are allowed:
ADDITIONAL CHANGES The $dateToString operator has also been updated ( Original descriptionThe date operators ($dayOfMonth, $dayOfWeek, $dayOfYear, $hour, $minute, $month, $week and $year) currently work for UTC. This causes the $group pipeline operator to insert certain rows in wrong bucket due to certain timezones being in another day. As an example, say you're showing website statistics for a US based company and at December 31st 2011 at 10:00 PM EST someone finally visits the website, if the aggregation framework didn't respect timezones (like it does now) it'd group the data point the next day (since it's stored as 2012-01-01T02:00:00Z). Which, if you're grouping data by year is quite the error as it would look like you'd have visitors from the future. Being able to set the timezone, either per query or per connection would solve this. |
| Comments |
| Comment by Kay Kim (Inactive) [ 21/Sep/17 ] |