Mongodb query on date has no results (java) -


my mongodb query not returning results , can't spot why.

here relevant contents of data:

> db.reports.find({},{enddate:1}) { "_id" : objectid("5182882ae4b032c67674c494"), "enddate" : isodate("2013-05-02t15:37:11.032z") } { "_id" : objectid("51828859e4b032c67674c495"), "enddate" : isodate("2013-05-02t15:37:57.749z") } 

so have 2 entries dates 2013-05-02 15:37:11-57

i want find entries date less or equal latest date, no results using query:

db.reports.find({ "enddate" : { "$lte" : { "$date" : "2013-05-02t15:37:11.032z"}}},{enddate:1}) 

i generating query in java using:

basicdbobject oldreportselector = (basicdbobject) basicdbobjectbuilder.start()     .add("enddate",          basicdbobjectbuilder.start().add("$lte",mydate).get())     .get(); 

what doing wrong here?

edit add: mydate calculated using:

date enddate = new date() date mydate = new date(enddate.gettime()-(interval*quantityarchivedreports)); 

currently interval = 86400000 , quantityarchivedreports = 4

the reason not getting in shell not using date format shell expects. try changing query to:

> db.reports.find({ "enddate" : { "$lte" : new date("2013-05-02t15:37:11.032z")}})  { "_id" : objectid("5182882ae4b032c67674c494"), "enddate" : isodate("2013-05-02t15:37:11.032z") } 

you can use shell verify if code has generated correct date data or not.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -