0

Good day,

First i saved a document in mongodb from java and for time i passed.

new Date();

so it saved a document like this.

"time" : {
    "_id" : ObjectId("5ad330019a04451b1ab8523d"),
    "created" : ISODate("2018-04-19T20:12:29.512+0000"), 
    "lastModified" : null
}

Now i would like to fetch all the documents matching date 2018-04-19 no matter what time it was.

how can i do that please help.

cool cool
  • 67
  • 10
  • This post will give you some information on querying on Date https://stackoverflow.com/questions/19819870/date-query-with-isodate-in-mongodb-doesnt-seem-to-work – Garreth Golding Apr 19 '18 at 20:50
  • Which technologies you are using? – Glim Apr 19 '18 at 21:09
  • 1
    A "single day" is actually a **range** of possible date values ( based in milliseconds since epoch ) between the "start" of the day you want inclusive of `0` seconds into the day, and the "start of the next day" exclusive `{ "$gte": startDate, "$lt": endDate }` – Neil Lunn Apr 19 '18 at 22:40
  • thats great. i was hoping that was supported by mongo java drivers. – cool cool Apr 20 '18 at 10:50

0 Answers0