Reputation: 21
How to group by isodate, preferably by year, month, day?
Upvotes: 2
Views: 2587
Reputation: 165
I am adding a simple group query, will count the number of entries for each date. Refer the following documentation for more date operators. https://docs.mongodb.com/v3.4/reference/operator/aggregation-date/
db.getCollection('callmodels').aggregate([
{$group: {_id: {day: {$dayOfMonth :"$date" }, month: {$month :"$date" }, year: {$year :"$date" }}, count: {$sum:1}}}
])
Upvotes: 5