title: How to filter JSON data from API by date range in JavaScript
body: <p>I want to filter the below JSON data by start date and end date, it should return the data between start date and end date, I tried to achieve using below code, but I'm doing wrong something to filter. I'm new to front end technologies like JavaScript. It would be appreciated if someone can correct me what I'm doing wrong here:</p>
  <p>The API data is like that seen below</p>
  <pre><code>{
     &quot;rec_id&quot;: 1,
     &quot;emp_id&quot;: 1,
     &quot;date&quot;: &quot;Jan 22, 2020&quot;,
     &quot;time_in&quot;: &quot;09:20&quot;,
     &quot;time_out&quot;: &quot;19:56&quot;,
     &quot;total_hours&quot;: 10.6,
     &quot;weekday&quot;: 4,
     &quot;name&quot;: &quot;Carlina Dahlberg&quot;,
     &quot;gender&quot;: &quot;Female&quot;,
     &quot;designation&quot;: &quot;Supervisor&quot;,
     &quot;department&quot;: &quot;Production&quot;,
     &quot;calculate&quot;: &quot;&quot;,
     &quot;basic_salary&quot;: 20000,
     &quot;per_day_salary&quot;: 1000
   },
   {
     &quot;rec_id&quot;: 2,
     &quot;emp_id&quot;: 2,
     &quot;date&quot;: &quot;Jan 22, 2020&quot;,
     &quot;time_in&quot;: &quot;08:33&quot;,
     &quot;time_out&quot;: &quot;13:16&quot;,
     &quot;total_hours&quot;: 4.72,
     &quot;weekday&quot;: 4,
     &quot;name&quot;: &quot;Brenden Greenacre&quot;,
     &quot;gender&quot;: &quot;Male&quot;,
     &quot;designation&quot;: &quot;Executive&quot;,
     &quot;department&quot;: &quot;Marketing&quot;,
     &quot;calculate&quot;: &quot;&quot;,
     &quot;basic_salary&quot;: 25000,
     &quot;per_day_salary&quot;: 1250
   },
  </code></pre>
  <p>This is my code file</p>
  <pre><code>async function getData(){
     let myData = await fetch(&quot;http://34.198.81.140/attendance.json&quot;)
       .then((respose) =&gt; {
         return respose.json() 
       })
       .then((data) =&gt; {
         return data;
       });
     let startDate =&quot;Feb 1, 2020&quot;;
     let endDate = &quot;Feb 29, 2020&quot;;
     let result = myData.filter((data) =&gt; {
       return data.date &gt;= startDate &amp;&amp; data.date &lt;=endDate;
     })
     console.log(result);
  }
  getData()
  </code></pre>
  <p>The data get filtered but not as per requirement, please see the  <a href="https://i.stack.imgur.com/J3npD.png" rel="nofollow noreferrer">screen shot of console</a> output. In the screen shot the Data come from 1 feb to 29 Feb but, the Data from 2 Feb to 9 Feb whole data is skip by filter function.</p>