title: MongoDb filter to get objecs between two dates
body: <p>I'm trying to get notifications between two dates using MongoDB;
  there are 7 days between two dates and using the function below to get data, but I'm always error code 500, any idea how to fix it?</p>
  <p>Sample data added below.</p>
  <p><strong>Function</strong></p>
  <pre><code>exports.getNotifications = async (req, res) =&gt; {
    try {
      const notifications = await notification.find({
        createdAt: { $gte: ISODate(date), $lt: ISODate(expires) },
      });
      return res.status(200).json({ notifications });
    } catch (error) {
      return res.status(500).json({
        ...error,
      });
    }
  };
  </code></pre>
  <p><strong>Sample Data</strong></p>
  <pre><code>  {
  &quot;_id&quot;: {
  &quot;$oid&quot;: &quot;613200ad493dae19e881e031&quot;
  },
  &quot;date&quot;: {
  &quot;$date&quot;: &quot;2021-09-03T11:01:47.972Z&quot;
  },
  &quot;expireDate&quot;: {
  &quot;$date&quot;: &quot;2021-09-10T11:01:47.972Z&quot;
  },
  &quot;seenBy&quot;: [],
  &quot;title&quot;: &quot;Social Karanlık Mod!&quot;,
  &quot;coverImage&quot;: &quot;https://www.linkpicture.com/q/Karanlık-Mod-1.png&quot;,
  &quot;actionType&quot;: &quot;basic&quot;,
  &quot;context&quot;: &quot;Profil sekmesindeki butondan karanlık ve aydınlık mod arasında geçiş yapabilirsiniz!&quot;,
  &quot;__v&quot;: 0
  }
  </code></pre>