Matching data between 2 dates in MongoDB Compass

Hi there,
There is a collection sessions with a field transactions that is an array of json-documents. Each element of this array has a field created_at (date of a transaction). I need to match all documents having transactions.0.created_at field between “2022-09-01” and “2022-10-01”.
So firstly the match-stage is created.
When it has only 1 condition,
{'transactions.0.created_at':{$gte: ISODate('2022-09-01')}} ,
all documents having transactions.0.created_at>=“2022-09-01” are shown, this is ok.
But when adding the second condition and getting the match-stage like
{'transactions.0.created_at':{$gte: ISODate('2022-09-01')}, 'transactions.0.created_at':{$lte: ISODate('2022-10-01')}},
I’m getting all documents even created in 2021.
It seems like OR connection, but as far as I know, all conditions in match-stage are connected via AND. Where can be a problem?

Please read the following for some explanations:

1 Like

Now it’s clear, thank you!

2 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.