ALL COVERED TOPICS

NoSQL Benchmarks NoSQL use cases NoSQL Videos NoSQL Hybrid Solutions NoSQL Presentations Big Data Hadoop MapReduce Pig Hive Flume Oozie Sqoop HDFS ZooKeeper Cascading Cascalog BigTable Cassandra HBase Hypertable Couchbase CouchDB MongoDB OrientDB RavenDB Jackrabbit Terrastore Amazon DynamoDB Redis Riak Project Voldemort Tokyo Cabinet Kyoto Cabinet memcached Amazon SimpleDB Datomic MemcacheDB M/DB GT.M Amazon Dynamo Dynomite Mnesia Yahoo! PNUTS/Sherpa Neo4j InfoGrid Sones GraphDB InfiniteGraph AllegroGraph MarkLogic Clustrix CouchDB Case Studies MongoDB Case Studies NoSQL at Adobe NoSQL at Facebook NoSQL at Twitter

NAVIGATE MAIN CATEGORIES

Close

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