title: How to get day wise records of particular month in mongodb?
body: <p>This is my schema</p>
  
  <pre><code>empname: {type: String},
  soldby: {type: String},
  expenseprice:{type:Number},
  expensedesc:{type:String},
  expensetype:{type:String},
  createdat: {type: Date, default: Date.now}
  </code></pre>
  
  <p>I tried this query</p>
  
  <pre><code>db.expenses.aggregate([
      {
          $project: {
              _id: 1,
              year: { $year: "$createdat" },
              month: { $month: "$createdat" },
              day: { $dayOfMonth: "$createdat" },
              expenseprice: 1
          }
      },
      {
          $group: {
             _id: {
                year: "$year",
                month: "$month",
                day: "$day"
             },
             sum: { $sum: "$expenseprice" }
          }
      }
  ])
  </code></pre>
  
  <p>I'm getting output as</p>
  
  <pre><code>{ "_id" : { "year" : 2015, "month" : 8, "day" : 15 }, "sum" : 200 }
  { "_id" : { "year" : 2016, "month" : 5, "day" : 20 }, "sum" : 150 }
  { "_id" : { "year" : 2016, "month" : 6, "day" : 29 }, "sum" : 250 }
  </code></pre>
  
  <p>I want only the records of particular year and particular month and in that month, day wise like this</p>
  
  <pre><code>{ "_id" : { "year" : 2016, "month" : 6, "day" : 28 }, "sum" : 150 }
  { "_id" : { "year" : 2016, "month" : 6, "day" : 29 }, "sum" : 200 }
  </code></pre>
  
  <p>I tried <code>$match</code> too</p>
  
  <pre><code>db.expenses.aggregate([
      {
          $project: {
              _id: 1,
              year: { $year: "$createdat" },
              month: { $month: "$createdat" },
              day: { $dayOfMonth: "$createdat" },
              expenseprice: 1
          }
      },
      {
          $match: {
              $eq: ["$month", 06]
          }
      },
      {
          $group: {
              _id: {
                  year: "$year",
                  month: "$month",
                  day: "$day"
              },
              sum: { $sum: "$expenseprice" }
          }
      }
  ])
  </code></pre>
  
  <p>But I'm getting error like this</p>
  
  <pre><code>assert: command failed: {
      "ok" : 0,
      "errmsg" : "bad query: BadValue unknown top level operator: $eq",
      "code" : 16810
  } : aggregate failed
  _getErrorWithCode@src/mongo/shell/utils.js:23:13
  doassert@src/mongo/shell/assert.js:13:14
  assert.commandWorked@src/mongo/shell/assert.js:266:5
  DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1215:5
  @(shell):1:1
  
  2016-06-29T16:20:47.754+0530 E QUERY    [thread1] Error: command failed: {
      "ok" : 0,
      "errmsg" : "bad query: BadValue unknown top level operator: $eq",
      "code" : 16810
  } : aggregate failed :
  _getErrorWithCode@src/mongo/shell/utils.js:23:13
  doassert@src/mongo/shell/assert.js:13:14
  assert.commandWorked@src/mongo/shell/assert.js:266:5
  DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1215:5
  @(shell):1:1
  </code></pre>