I want to aggregate entries whose date is less than 1 week old from today.
{ "collection": "my-lovely-collection", "aggregate": [ {"$match": {"some_field": { "$regex": "awesome*"}}}, {"$match": {"created": {"$lt": {"$dateToString": {"date": {"$dateSubtract": {"startDate": {"$currentDate": {"$type": "date"}}, "unit": "day", "amount": 7 }}}}}}}, {"$group": {"_id": "$some_field", "count": {"$sum": 1 }}}, {"$sort": [{"name": "count", "direction": 1}]} ] } When I use a hard-coded date for today everything works fine (but that's not what I want)
{"$match": {"created": {"$lt": "2022-08-29"}}}
new Date()- any ideas? thanks !