title: Mongodb: Perform a Date range query from the ObjectId in the mongo shell
body: <p>I have a collection that looks like this:</p>
  
  <pre><code>{
    _id: ObjectId("50a68673476427844b000001"),
    other fields
  }
  </code></pre>
  
  <p>I want to do a range query to find records between two dates.  I know that I can get the date from the ObjectId in the mongo shell var doing this:</p>
  
  <pre><code>var aDate = ObjectId().getTimestamp()
  </code></pre>
  
  <p>but there isn't a way (as far as I can figure out at the moment) to create an ObjectId consisting of just the timestamp portion - I think my ideal solution is non-functioning mongo shell code would be:</p>
  
  <pre><code>var minDate = ObjectId(new Date("2012-11-10"));
  var maxDate = ObjectId(new Date("2012-11-17"));
  </code></pre>
  
  <p>Use the find with the minDate and MaxDate as the range values.</p>
  
  <p>Is there a way to do this in the SHELL - I'm not interested in some of the driver products.</p>