Skip to content

Instantly share code, notes, and snippets.

@lilongen
Created January 5, 2017 09:59
Show Gist options
  • Save lilongen/5fcb1fce087c8ba514d826c50c4c038d to your computer and use it in GitHub Desktop.
Save lilongen/5fcb1fce087c8ba514d826c50c4c038d to your computer and use it in GitHub Desktop.
mongo-date-range-query
var objIdMin = ObjectId(Math.floor((new Date('1990/10/10'))/1000).toString(16) + "0000000000000000")
var objIdMax = ObjectId(Math.floor((new Date('2011/10/10'))/1000).toString(16) + "0000000000000000")
db.myCollection.find({_id:{$gt: objIdMin, $lt: objIdMax}})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment