I'm currently trying to group a set of documents by the week number of an exit_time field.
I can do so fine with the $week aggregation like so.
$group: {
_id: {$week: "$exit_time"}
}
However if I try to include the timezone like in the mongodb documentation I get the following error.
MongoError: can't convert from BSON type object to Date
Here's the code snippet that's causing it. As far as I can tell it is how the examples do it in the mongo documentation.
$group: {
_id: {
$week: {
date: "$exit_time",
timezone: "America/Tijuana"
}
}
}
Here's the relevant documentation. https://docs.mongodb.com/manual/reference/operator/aggregation/week/
Has anyone ran into a similar issue that can point me in the right direction?