I have the following code:
DBObject groupFields = new BasicDBObject("_id", "$Date");
groupFields.put("count", new BasicDBObject("$sum", 1));
DBObject groupBy = new BasicDBObject("$group", groupFields);
stages.add(groupBy);
DBObject project = new BasicDBObject("_id", 0);
project.put("count", 1);
project.put("Date", "$_id");
stages.add(new BasicDBObject("$project", project));
DBObject sort = new BasicDBObject("$sort", new BasicDBObject("Date", 1));
stages.add(sort);
to group by Date and show the count which works fine but the problem is my date is in the following format:
"Date" : ISODate("2014-11-19T04:11:22.000Z")
and as you can see it has time as well but I want to group by date without considering time so I want to consider my date like this:
2014-11-19T04:00:00.000Z but I do not know how to do that ...is there any mongodb function like date in mysql to do that?
Can anyone help?
Update:
I think this might be helpful but still do not know how to do it: link that might help