title: MongoDB Aggregate field between two dates
body: <p>I want to aggregate complaints based on status between two dates.</p>
  <p>Sample Data :</p>
  <p><a href="https://i.stack.imgur.com/jUTcf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jUTcf.png" alt="enter image description here" /></a></p>
  <p><a href="https://pastebin.pl/view/f2f5312c" rel="nofollow noreferrer">In JSON format</a></p>
  <p>Code :</p>
  <pre class="lang-js prettyprint-override"><code>const result = await Complaint.aggregate([
              {
                  $match: {
                      createdAt: {
                          $gte: &quot;2021-08-31T18:30:00.000Z&quot;,
                          $lt: &quot;2021-09-30T18:29:59.999Z&quot;,
                      },
                  },
              },
              { $group: { _id: &quot;$status&quot;, count: { $sum: 1 } } },
          ]);
  
  </code></pre>
  <p>Expected result :</p>
  <pre class="lang-js prettyprint-override"><code>[ { _id: 'progress', count: 1 }, { _id: 'raised', count: 4 } ]
  </code></pre>
  <p>but result is always coming as empty <code>[]</code></p>