Hi @George_Richardson and welcome to the community.
If I understand the query correctly, you are trying to find the documents that match with the current date. Based on the above aggregation stage, I tried to insert some data data into the collection as:
Atlas atlas-xp4gev-shard-0 [primary] test> db.testMatch.find()
[
{
_id: ObjectId('65ddf76921382574857736dc'),
timestamp: ISODate('1999-12-31T18:30:00.000Z'),
data: 'Sample Data 1'
},
{
_id: ObjectId('65ddf76921382574857736dd'),
timestamp: ISODate('2024-02-27T10:15:00.000Z'),
data: 'Sample Data 2'
},
{
_id: ObjectId('65ddf76921382574857736de'),
timestamp: ISODate('2024-02-27T12:30:00.000Z'),
data: 'Sample Data 3'
},
{
_id: ObjectId('65ddf76921382574857736df'),
timestamp: ISODate('2024-02-26T15:45:00.000Z'),
data: 'Sample Data 4'
},
{
_id: ObjectId('65ddf76921382574857736e0'),
timestamp: ISODate('2024-02-26T18:00:00.000Z'),
data: 'Sample Data 5'
},
{
_id: ObjectId('65ddf76921382574857736e1'),
timestamp: ISODate('2024-02-26T20:30:00.000Z'),
data: 'Sample Data 6'
},
{
_id: ObjectId('65ddf76921382574857736e2'),
timestamp: ISODate('2024-02-25T09:00:00.000Z'),
data: 'Sample Data 7'
},
{
_id: ObjectId('65ddf76921382574857736e3'),
timestamp: ISODate('2024-02-25T11:20:00.000Z'),
data: 'Sample Data 8'
},
{
_id: ObjectId('65ddf76921382574857736e4'),
timestamp: ISODate('2024-02-25T13:45:00.000Z'),
data: 'Sample Data 9'
},
{
_id: ObjectId('65ddf76921382574857736e5'),
timestamp: ISODate('2024-02-24T14:00:00.000Z'),
data: 'Sample Data 10'
}
]
and I tried to use the match stage as:
[
{
$match: {
timestamp: {
$gte: new Date(
new Date().setUTCHours(0, 0, 0, 0)
),
},
},
},
]
which gives the output as:
[
{
_id: ObjectId('65ddf76921382574857736dd'),
timestamp: ISODate('2024-02-27T10:15:00.000Z'),
data: 'Sample Data 2'
},
{
_id: ObjectId('65ddf76921382574857736de'),
timestamp: ISODate('2024-02-27T12:30:00.000Z'),
data: 'Sample Data 3'
}
]
Let us know if the above query satisfies your requirement.
Best Regards
Aasawari