Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-28611

Add the tzExpression argument to the date extraction functions

    • Minor Change
    • Query 2017-06-19, Query 2017-07-10

      The new functionality adds the timezone argument to the date extraction functions ($year, $month, $day, $hour, $minute, $second, $millisecond, $isoYear, $isoWeekYear, and $isoDayOfWeek). Currently the operators only take a single value:

          { "$month" : ISODateValue }
      

      Because it is not possible to add another argument to this, the syntax has
      been extended to:

          { "$month" : { "date" : ISODateValue } }
      

      And then with the time zone argument added, it becomes:

          { "$month" : {
              "date" : ISODateValue,
              "timezone": timeZoneIdentifier
          } }
      

      For example:

          { $hour: {
              date: ISODate("1978-12-22T08:15:00Z"),
              timezone: "Europe/Amsterdam"
          } }
      

      Would return 09 (One hour later than UTC).

      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 dateString that you provided will be interpreted as it was in that time zone.

            Assignee:
            charlie.swanson@mongodb.com Charlie Swanson
            Reporter:
            ian@mongodb.com Ian Whalen (Inactive)
            Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: