I'm trying to aggregate using group on datetime value on below collection,
{
"_id" : 104801,
"requests" : {
"rstTimeStamp" : ISODate("2014-11-11T10:30:13.577Z"),
"emailId" : "user1@example.com"
}
}
{
"_id" : 104802,
"requests" : {
"rstTimeStamp" : ISODate("2014-11-11T12:40:13.577Z"),
"emailId" : "user2@example.com"
}
}
{
"_id" : 104803,
"requests" : {
"rstTimeStamp" : ISODate("2014-11-12T12:40:13.577Z"),
"emailId" : "user3@example.com"
}
}
And expecting the output to show total number of requests for particular date for e.g. date 2014-11-11 has 2 requests. But due to the time value in the date it is considering every date as a single document.
Any help on this will be appreciated.
EDIT: My query is as follows:
db.clrequests.aggregate({ $group : { _id : "$requests.rstTimeStamp", total : {$sum : 1} } })