3

I am trying to query dates in mongodb.

The dates are stored as ISODate("2015-10-08T05:48:55.778+0000").

Now how should i do query like $gte or $lte.

I have been using Play plugin for reactive mongo

To query from the mongo shell, I would need to query with=>

{"endDateTime":{"$eq": new Date("2017-10-08T05:48:55.778+0000")}

OR,

{"endDateTime":{"$eq": ISODate("2017-10-08T05:48:55.778+0000")}

So, what should I do to query it using play reactive mongo. I have been using JodaTime. I am generating the Json Object of the query, and feeding to the find() api straightaway.

*Yes there a lot suggestion in SO, about the topic, but none of them seem to help me in this case. I could give more info if needed.

Update Answer:

Seems like I had some confusion, when converting the dates.

When I tried converting the String Date to Joda DateTime , the result when I print it in console, it would be shown as timestamp,but when I sent it to reactive mongo find it would convert to some form of string date "2015-10-08T05:48:55.778+0000".

So, I had to retrieve the millisecond conversion and send it to the respective api, and mongo would process without any issues.

mane
  • 1,149
  • 16
  • 41
  • If you look at the [documentation](http://reactivemongo.org/releases/0.11/documentation/bson/typeclasses.html#provided-handlers), you can see that date/time is supported as `java.util.Date`. – cchantep Dec 21 '15 at 20:29

0 Answers0