Description
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.