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

$dateTrunc thinks a date is a string

    • Type: Icon: Bug Bug
    • Resolution: Gone away
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 5.0.6
    • Component/s: None
    • ALL

      Since updating to MongoDB Server v5.0.6. Community Version, $dateTrunc.date thinks any date is a string. For example:

      {
          $expr: {
            $lt: ["$paidDate", {
                $dateAdd: {
                  startDate: {
                    $dateTrunc: {
                      date: new Date(), // <<=======
                      unit: "day",
                      binSize: 1,
                      timezone: "Europe/London"
                    }
                  },
                  unit: "day",
                  amount: 1,
                  timezone: "Europe/London"
                }
            }]
          }
        }
      

      The above gives this error:

      PlanExecutor error during aggregation :: caused by :: $dateTrunc requires 'date' to be a date, but got string

      All existing queries via Compass and C++ are broken. If this is an official update to how this aggregate statement works, there is no updated documentation as far as I can see.

            Assignee:
            eric.sedor@mongodb.com Eric Sedor
            Reporter:
            adam@adamcrowe.net Adam Crowe
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: