Hi there,
Looks like your query has an extra comma after the less than date which is not necessary and also, please try something similar to below using ISO function for date conversion and see if that helps.
db.collection.find({
"LogTimestamp": {
"$gte": ISODate("2021-01-13T00:00:00.000Z"),
"$lt": ISODate("2023-01-14T00:00:00.000Z")
}
})
Another example called out in this document: https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/tutorial-aggregation#example-with-multiple-stages
db.sales.aggregate([
{ $match: { date: { $gte: "2021-01-01", $lt: "2021-03-01" } } },
{ $group: { _id: "$category", totalSales: { $sum: "$sales" } } },
{ $sort: { totalSales: -1 } },
{ $limit: 5 }
])
Hope this info helps.
Please don’t forget to Accept Answer
and Yes
for "was this answer helpful" wherever the information provided helps you, this can be beneficial to other community members.