title: Fetch all records from database before a specific date
body: <p>I am developing an <code>android</code> application which calls an <code>api</code> made in <code>php</code> to get the list of service requests stored in the <code>MySQL</code> database. The table has <code>scheduled_date</code> column which has the date stored in it in the following format: <code>21/5/2021</code>.</p>
  <p>I want to get all the records before today so for example, if I booked a service yesterday and scheduled it for lets say <code>28/5/2021</code>, then when I load the app on <code>28/5/2021</code>, the <code>api</code> should also return me this scheduled service along with other requests but the <code>api</code> never returns it.</p>
  <p>I am storing two types of requests in my table.
  One is of the regular type and the other one is the scheduled one so for that, I have put two columns in my table (<code>is_scheduled</code>, <code>scheduled_date</code>) so if the request is of regular type, then scheduled_date is set to be <code>NULL</code> by default and is_scheduled is set to be No by default.</p>
  <p>Below is my logic that I have implemented so far.</p>
  <pre><code>$today_date = date('d-m-Y');
  
  $get_scheduled_date = mysqli_query($conn, &quot;SELECT * FROM tbl_requests WHERE is_active = 0&quot;);
  $req_array = array();
  if(mysqli_num_rows($get_scheduled_date) &gt; 0){
      while($data = mysqli_fetch_assoc($get_scheduled_date)){
          $date_got=$data['scheduled_date'];
          if(!is_null($date_got)){
              $formatted_date=date('d-m-Y', strtotime($date_got));
              if($today_date&lt;$formatted_date){
                  $req_array[] = $data;
              }    
          }
          else{
              $req_array[] = $data;
          }
          
      }
      $newArray = array(&quot;available_requests&quot;=&gt;$req_array);
      json_response(200, &quot;&quot;, $newArray);
  }else{
      $req_array = array();
      $newArray = array(&quot;available_requests&quot;=&gt;$req_array);
      json_response(200, &quot;&quot;, $newArray);
  }
  </code></pre>