1

Well, I want fetching all results grouped by date(year, month and day), no datetime(h:i:s).

In MySQL i can write:

SELECT COUNT(1), date(created)
FROM views 
WHERE owner = 1
GROUP BY date(created);

And Mongo? well, i have a idea, but dont work... i dont know how to set "date(created)"...

db.views.group({
    "key": {
        "created": true
    },
    "initial": {
        "sum_id": 0
    },
    "reduce": function(obj, prev) {
        prev.sum_id = prev.sum_id + 1;
    },
    "cond": {
        "owner": 1
    }
});

Please, if you know how to query grouped by date, tell me, i really need... Thanks

Olaf Erlandsen
  • 5,817
  • 9
  • 41
  • 73
  • possible duplicate of [group by dates in mongodb](http://stackoverflow.com/questions/5168904/group-by-dates-in-mongodb) – Blakes Seven Jul 13 '15 at 23:15

0 Answers0