I am using MongoDB in Jupyter notebook and I'm trying to select data based on their dates. After spending numerous unsuccesfull hours with this approach, I've turnt to another approach, which gave me the intended results. However, it has been bugging me for days, that I wasn't able to obtain the same results by aggregating the data on the dates. Are there any MongoDB champs, who can enlighten me about my mistake(s)?
The collection looks like this:
{
'_id': ObjectId('foobar123'),
'xRounds': 30,
'yRounds': 30,
'survey': ObjectId('foobar789'),
'createdAt': ISODate('2021-10-01T18:36:18.407Z')
}
The query looks like this:
match = {
"$match": {
'xRounds': { "$gt": 9 },
'yRounds': { "$gt": 9 },
'survey': {"$ne": None},
'createdAt': {"$gt": "ISODate('2020-10-06T12:09:50.817Z')", "$lt": "ISODate('2021-10-07T12:09:50.817Z')"}
}
}
The above query gave the result 0, but I was expecting 10 documents. Any idea about what went wrong?
Thanks in advance!