title: How to find/query dates by year in MongoDB
body: <p>Given some sample collection data:</p>
  
  <pre><code>{
      "question" : "Which do you usually eat?",
      "pubDate" : ISODate("1999-01-24T13:00:00Z"),
      "_id" : ObjectId("51d7f9e231d2fe0000000002"),
  }
  {
      "question" : "Which language do you usually speak?",
      "pubDate" : ISODate("2013-12-02T13:00:00Z"),
      "_id" : ObjectId("51d8a476a6b9d70000000006"),
  }
  </code></pre>
  
  <p>How would you query for all questions from 1999? What I'm after is something like:</p>
  
  <pre><code>db.poll.find({pubDate.year: 1999})
  </code></pre>
  
  <p>I've found that I can take the following <a href="http://cookbook.mongodb.org/patterns/date_range/" rel="nofollow">date range query approach</a>, but it seems like there should be a simpler way:</p>
  
  <pre><code>db.poll.find({
    pubDate: { 
      $gte: new Date("1 Jan, 1999"), 
      $lt: new Date("1 Jan, 2000")
    }
  });
  </code></pre>