Query date based using milliseconds time on MongoDB

I need to search all records that match a date condition. On MongoDB I’ve a bunch of data like this:

{
    "_id" : "9ed3b937-0f43-4613-bd58-cb739a8c5bf6",
    "userModels" : {
        "5080" : {
            "generated_date_timestamp" : NumberLong(1413382499442),
            "model_id" : 5080,
        },
    }
    "values" : {}
}

With this query, is possible to do date / time based search:

db.anonProfile.find({ 
   "userModels.5080.generated_date_timestamp" : 
      { 
         "$gte" : ISODate("2013-10-01T00:00:00.000Z").getTime() 
      }
});
Tagged

Leave a Reply