So getting the counts for a whole month you can use the date operators in the aggregation pipeline. You can also combine with a $match
in order to get the range of dates you want.
var start = new Date("2013-06-01");
var today = new Date();
db.collection.aggregate([
{ "$match": {
"date": { "$gte": start, "$lt": today }
}},
{ "$group": {
"_id": {
"year": { "$year": "$date" },
"month": { "$month": "$date" },
},
"count": { "$sum": 1 }
}}
])