title: How can I get data from mongoDB between a certain date (date is stored as createdOn in our document)?
body: <p>This my query - </p>
  
  <pre><code>  var Query = Offer
      .where('isDeleted').equals(false)
      .populate('country')
      .populate('state')
      .populate('city')
      .populate('store')
      .populate("createdBy")
      .populate("main_cat")
      .populate("grab_by")
      .populate("merchant_id")
      .sort('store_name');
  
  if (typeof querydata.country != 'undefined' &amp;&amp; querydata.country !== '') {
      Query.where('country').in(querydata.country)
  }
  if (querydata.state.length &gt; 0) {
  
      querydata.state = querydata.state.split(",");
      Query.where('state').in(querydata.state);
  }
  if (querydata.city.length &gt; 0) {
      querydata.city = querydata.city.split(",");
      Query.where('city').in(querydata.city);
  }
  //here i am trying to get data from start to end date
  if ((req.query.start_date !== '' &amp;&amp; typeof req.query.start_date !== 'undefined') &amp;&amp; (req.query.end_date !== '' &amp;&amp; typeof req.query.end_date !== 'undefined')) {
      var startdate = new Date(req.query.start_date);
      var enddate = new Date(req.query.end_date);
      //(startdate);
      enddate.setDate(enddate.getDate() + 1);
      Query.where(('createdOn').split('T')[0]).gte(startdate).lte(enddate);
  }
  </code></pre>
  
  <p>In the last if else condition I am trying where I am trying to get between start date and end date. Please suggest how should I write my query for the same. Should I use momentJS for the same.
  The main purpose of this code is to get the data between a date which will be downloaded by the user in CSV format.</p>
  
  <p>This is the schema of the document: <a href="https://i.stack.imgur.com/YjPl8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YjPl8.png" alt="enter image description here"></a></p>