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

Day-of-year (%j) parsing inconsistency

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Execution
    • QE 2023-03-06, QE 2023-03-20, QE 2023-04-03

      When I specify both %j for day of year and %m for month {'$dateFromString': {'dateString': '2007-01-11', 'format': '%Y-%j-%m'}} (note the order), the result is 2007-11-02T00:00:00.000Z - $j is treated like $d (but with an initial value of 0).

      If I specify %Y-%j-%m-%d (input 2007-01-11-05), %j is ignored, and the result is 2007-11-05T00:00:00.000Z.

      The strings "%Y-%m-%d-%j" and "%Y-%j-%m-%d" give different results for the same (re-ordered) values.

      Since it is always an error to specify a day of year together with either a month or day of month, I would expect an error (similar to how we treat potentially incompatible timezones).

            Assignee:
            kyle.suarez@mongodb.com Kyle Suarez
            Reporter:
            maxim.katcharov@mongodb.com Maxim Katcharov
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: