I have a collection called Document in MongoDB. Documents in this collection have a field called CreationDate stored in ISO date type. My task is to count the number of docu
Another easier way you can convert ISODate to various date formats is to use the $dateToString aggregation operator.
db.collection.aggregate([ { $group: { _id: { $dateToString: { format: "%Y-%m-%d %H:%M", date: "$CreationDate" } }, count: { $sum: 1 } }}, { $sort : { count: -1 }} ])