title: How to save in MongoDB with timestamp and then retrieve results by week
body: <p><strong>I have this snippet right here which saves a user in my MongoDB:</strong></p>
  
  <pre><code>router.post('/adduser', function(req, res) {
      var db = req.db;
      var document = req.body;
      var codeResponse = code();
      var timestamp = new Date();
      document.code = codeResponse;
      document.timestamp = timestamp;
      db.collection('userlist').insert(document, function(err, result){
          res.send(
              (err === null) ? { msg: '',code: codeResponse } : { msg: err }
          );
      }); });
  </code></pre>
  
  <p>As you can see it also generates a <code>timestamp via the new Date();</code> function in JS.</p>
  
  <p><strong>How can retrieve users by week?</strong></p>
  
  <p>I tried this:</p>
  
  <pre><code>router.get('/winnerlist', function(req, res) {
      var db = req.db;
      var start = new Date(2014, 6, 14);
      var end = new Date(2014, 6, 29);
      db.collection('userlist').find({"timestamp": {"$gte": start, "$lt": end}}).toArray(function (err, items) {
          res.json(items);
      });
  });
  </code></pre>