MongoDB Tricks: Storing dates and Group By Day
Nice trick discovered after hitting a performance problem when having to group results by date:
So I quickly determined from this that I was storing the date and time in the wrong way. I need to split up the date and time. I now have this:
{ “_id” : ObjectId(“4bfea7246c6151d127f80100”), ... “created” : { “d” : “2010-03-29”, “t” : “20:15:34” } }
Note that using a timestamp would not work either. But I’m wondering if this is the only solution for grouping by day?
via: http://developingwithstyle.com/articles/2010/07/09/handling-dates-in-mongodb.html