Database
[{id:1,reservations:[{from:"2022-01-01",to:"2022-03-31"},{from:"2022-04-01",to:"2022-06-01"},{from:"2022-07-01",to:"2022-08-01"}]},{id:2,reservations:[{from:"2022-01-01",to:"2022-12-31"}]},{id:3,reservations:[{from:"2022-02-01",to:"2022-06-30"}]}]
Query
db.collection.aggregate([{$match:{reservations:{$elemMatch:{$or:[{to:{$lt:"2022-07-01"},},{from:{$gt:"2022-08-31"}}]}}}},{$addFields:{reservations:{$filter:{input:"$reservations",cond:{$or:[{$lt:["$$this.to","2022-07-01"]},{$gt:["$$this.to","2022-08-31"]}]}}}}}])