Im trying to create a query to search for all collections that are in between of two Date strings, however all my attempts have failed and every time I try a query it always return no results
this is the query im using:
const intialDate = new Date('2024-05-23T06:00:00.000Z');
const endDate = new Date('2024-05-24T20:44:02.172Z');
const dispoquery = this.guestModel.find({
$and: [
{
$or:[
{
initial: {
$gte: intialDate
}
},
{
end: {
$lte: endDate
}
},
]
}
]
}).catch((err) => {
return err;
})
.then((doc:any)=> {
return doc
})
I need all documents that comply this assortment:
intial >= intialDate || end <= endDate
But I always get no results
this is a sample data of my collection:
{
"folio": "W1013",
"nombre": "CArlos",
"llegada": "2024-05-23T06:00:00.000Z",
"salida": "2024-05-24T19:52:11.050Z",
"__v": 0
}
Can someone please tell me what im doing wrong please?