Reputation: 812
I am trying to search some data in collection so i add {dCreatedAt: ISODate('2022-11-16')}
in filter so i have two data having following values in db
dCreatedAt: 2022-11-16T00:00:00.000+00:00,
dCreatedAt: 2022-11-15T13:31:18.513+00:00
Filter showing only first data not the second one.
Upvotes: 0
Views: 71
Reputation: 16033
If you really want, you can use an aggregation pipeline:
db.collection.aggregate([
{
$match: {
$expr: {
$eq: [
{$dateTrunc: {date: "$dCreatedAt", unit: "day"}},
{$dateFromString: {dateString: "2022-11-16"}}
]
}
}
}
])
See how it works on the playground example
Upvotes: 1