This query which should filter results by the month seems to be working fine. But I can't figure out how to add a year filter as well.
db.collection.find({
"$expr": {
"$eq": [{ "$month": "$timestamp" }, 12]
}
});
I tried to come up with something like this but no success.
db.collection.find({
"$expr": {
"$and": [
{ "$eq": [{ "$month": "$timestamp" }, 12] },
{ "$eq": [{ "$year": "$timestamp" }, 2018] }
]
}
});
How to do that properly?