title: Filtering & sorting by dates in MongoDB's oplog
body: <p>I'm trying to filter oplog.rs to view operations that were logged after a certain date. But comparison operators don't seem to work with dates in MongoDB:</p>
  
  <pre><code>db['oplog.rs'].find({ts: {$gte: ISODate("2014-12-15T00:00:00Z")}})
  </code></pre>
  
  <p>What's confusing is a lot of online sources are saying to do it this way but it is obviously not working. I want to return results where the ts field is at least December 15th or more recent, but I am getting results that are clearly before this period. If I switch $gte with $lte no results at all are displayed, even though there are definitely entries both before and after this specified date. </p>
  
  <p>Also, I can't seem to sort the results either. If I try this:</p>
  
  <pre><code>db['oplog.rs'].find().sort({ts: -1})
  </code></pre>
  
  <p>I get this: </p>
  
  <pre><code>error: {
      "$err" : "Runner error: Overflow sort stage buffered data usage of 33566005 bytes exceeds internal limit of 33554432 bytes",
      "code" : 17144
  }
  </code></pre>
  
  <p>If I could filter the results to make them more recent, I am hoping it would overcome this sorting error, but I can't even do that with MongoDB's basic operators. How can I filter the results of a find operation by date? </p>