[SERVER-28613] Add the $dateToParts and $dateFromParts A/F operators Created: 04/Apr/17 Updated: 06/Dec/17 Resolved: 29/Jun/17 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Aggregation Framework, Querying |
| Affects Version/s: | None |
| Fix Version/s: | 3.5.10 |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Ian Whalen (Inactive) | Assignee: | Derick Rethans |
| Resolution: | Done | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||||||||||
| Sprint: | Query 2017-07-10 | ||||||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||||||
| Linked BF Score: | 0 | ||||||||||||||||||||||||||||
| Description |
|
The new $dateToParts operator simplifies having multiple single date value extraction operators into a single one. Its syntax is:
The "timezone" argument is optional, and must evaluate to specify an Olson Timezone Identifier such as "Europe/London" or "America/New_York", or, a UTC offset string in the forms: "+03", "-0530", and "+04:45". If you specify a timezone argument it means that the date that you provided will be interpreted as it was in the given time zone. The result of the operator is a sub-document with the broken down parts, expressed in the (optionally) given time zone:
$dateToParts also supports a third boolean argument, iso8601. If set to true, instead of year, month, and day, it returns the ISO 8601 isoYear, isoWeekYear, and isoDayOfWeek fields representing an ISO Week Date. With the same date, the example is represented as:
The $dateFromParts operator does the opposite of the $dateToParts operator and constructs a new Date value from its constituent parts, with the possibility of interpreting the given values in a different time zone. Its syntax is either::
or:
Each argument's expression needs to evaluate to a number. This means the source can be either double, NumberInt, NumberLong, or Decimal. Decimal and double values are only supported if they convert to a NumberLong without any data loss. Notes
|
| Comments |
| Comment by Githook User [ 30/Jun/17 ] |
|
Author: {u'username': u'derickr', u'name': u'Derick Rethans', u'email': u'github@derickrethans.nl'}Message: |
| Comment by Githook User [ 29/Jun/17 ] |
|
Author: {u'username': u'derickr', u'name': u'Derick Rethans', u'email': u'github@derickrethans.nl'}Message: |