title: MongoDB / Pymongo Query with Datetime
body: <p>I am trying to retrieve the data I have inserted into mongodb via pymongo.</p>
  
  <p>My code for insert is below (after parsing via regex)</p>
  
  <pre><code>if connection is not None:
      db.model.insert({"time": datetime.datetime(int(int3), int(int1),
                                                 int(int2), int(int4),
                                                 int(int5), int(int6),
                                                 int(int7))})
  </code></pre>
  
  <p>I then entered two data points in the shell.</p>
  
  <pre><code>&gt;&gt;&gt; start = datetime.datetime(2012, 2, 2, 6, 35, 6, 764)
  &gt;&gt;&gt; end = datetime.datetime(2012, 2, 2, 6, 55, 3, 381)
  </code></pre>
  
  <p>I then tried to query the range of data between these two data points and received what is returned.</p>
  
  <pre><code>&gt;&gt;&gt; db.wing_model.find({'time': {'$gte': start, '$lt': end}})
  &lt;pymongo.cursor.Cursor object at 0x0301CFD0&gt;
  &gt;&gt;&gt; db.wing_model.find({'time': {'$gte': start, '$lt': end}})
  &lt;pymongo.cursor.Cursor object at 0x0301C110&gt;
  </code></pre>
  
  <p>Data is listed below.</p>
  
  <pre><code>[02/02/2012 06:32:07.334][INFO]
  [02/02/2012 06:32:07.334][INFO]
  [02/02/2012 06:32:07.334][INFO]
  [02/02/2012 06:32:13.711][INFO]
  [02/02/2012 06:32:13.711][INFO]
  [02/02/2012 06:32:13.711][INFO]
  [02/02/2012 06:32:22.473][INFO]
  [02/02/2012 06:32:22.473][INFO]
  [02/02/2012 06:32:22.473][INFO]
  [02/02/2012 06:35:06.764][INFO]
  [02/02/2012 06:35:06.765][INFO]
  [02/02/2012 06:35:06.765][INFO]
  [02/02/2012 06:54:52.008][INFO]
  [02/02/2012 06:54:52.008][INFO]
  [02/02/2012 06:54:52.008][INFO]
  [02/02/2012 06:54:59.512][INFO]
  [02/02/2012 06:54:59.512][INFO]
  [02/02/2012 06:54:59.512][INFO]
  [02/02/2012 06:55:03.381][INFO]
  [02/02/2012 06:55:03.381][INFO]
  [02/02/2012 06:55:03.381][INFO]
  [02/02/2012 06:55:06.142][INFO]
  [02/02/2012 06:55:06.142][INFO]
  [02/02/2012 06:55:06.142][INFO]
  [02/02/2012 06:55:09.652][INFO]
  [02/02/2012 06:55:09.652][INFO]
  [02/02/2012 06:55:09.652][INFO]
  [02/02/2012 06:55:13.396][INFO]
  [02/02/2012 06:55:13.396][INFO]
  </code></pre>
  
  <p>How do I get my query to return everything between the 'start' and 'end' data? </p>
  
  <p>Also, how do I receive this in an intelligible form?</p>
  
  <p>Finally, why does the same query return different cursor object locations?</p>
  
  <p>Thank you.</p>