title: Inserting and Querying Date with MongoDB and Nodejs
body: <p>I need some help finding a record by date in mongodb and nodejs.</p>
  
  <p>I add the date to the json object in a scraping script as follows:</p>
  
  <pre><code>jsonObj.last_updated = new Date();
  </code></pre>
  
  <p>This object is inserted into mongodb. I can see it as follows:</p>
  
  <pre><code> "last_updated" : "2014-01-22T14:56:59.301Z"
  </code></pre>
  
  <p>Then in my nodejs script I do a findOne():</p>
  
  <pre><code> var jObj = JSON.parse(line.toString());
  
   collection.findOne(jObj,function(err, doc) {
     if (doc){
       console.log(doc._id);
     } else  {
       console.log('not found');
     }
   });
  </code></pre>
  
  <p>The object is not found. If I remove the last_updated field from the object it is found so it is definitely where the problem is.</p>
  
  <p>If I isolate the field as follows:</p>
  
  <pre><code>collection.findOne({last_updated: '2014-01-22T14:56:59.301Z'},function(err, doc) {
    if (doc){
      console.log(doc._id);
    } else  {
      console.log('not found');
    }
  });
  </code></pre>
  
  <p>Nothing comes back either. What am I doing wrong please?    </p>