title: Returning data where datetime columns are between user input of date, hours and minuets combined
body: <p>I am having major issues with returning data from my table where dates are between six user inputs. A user can select a from date, from hours, from minuets along with to date, to hours and to minuets.The aim is, if the input is found in the table a Jquery alert is displayed.</p>
  
  <p>My table has two "datetime" cols and contain the start date and time and the end date and time. i.e</p>
  
  <p>Start date and time "2018-09-14 08:00:00"
  End date and time: "2018-09-14 16:00:00"</p>
  
  <p>On the user input form I have the following textfields:</p>
  
  <ul>
  <li>RoomFromDate, date selected from a popup calander. The selected date
  is at this stage in the format of "d-m-Y"</li>
  <li>RoomToDate, date selected from a popup calander. The selected date is
  at this stage in the format of "d-m-Y"</li>
  <li>RoomFromTimeH, selected from a dropdown menu containing times in
  hours from 00 to 23</li>
  <li>RoomToTimeH, selected from a dropdown menu containing times in hours
  from 00 to 23</li>
  <li>RoomFromTimeM, selected from a dropdown menu containing times in
  minuets from 00 to 59</li>
  <li>RoomToTimeM, selected from a dropdown menu containing times in
  minuets from 00 to 59</li>
  </ul>
  
  <p>When the "RoomToTimeM" is selected it triggers a Jquery/Ajax script that posts the query information to a php script "check_record_avail.php" which runs the query and returns the data if a record is found.</p>
  
  <p>Looking at the browser console I can see that the corret user selections are Posted via Ajax to "check_record_avail.php", see below. </p>
  
  <pre><code>console.log("Check date and time:",fromdate, fromhours, frommins, todate, tohours, tomins);
  FromDate: 14-09-2018
  FromTimeHours: 08
  FromTimeMins: 00
  ToDate: 14-09-2018
  ToTimeHours: 16
  ToTimeMins: 00
  </code></pre>
  
  <p>In my "check_record_avail.php" script I have the following:</p>
  
  <pre><code>if(isset($_POST['FromTimeHours'])){
  $FromTime = $_POST['FromTimeHours'];
  }
  //echo "From time ". $FromTime."&lt;br/&gt;";
  
  if(isset($_POST['FromTimeMins'])){
  $FromTimeMins = $_POST['FromTimeMins'];
  }
  //echo "From time mins ". $FromTimeMins."&lt;br/&gt;";
  
  if(isset($_POST['ToDate'])){
  $ToDate = $_POST['ToDate'];
  }
  //echo "To date ". $ToDate."&lt;br/&gt;";
  
  if(isset($_POST['ToTimeHours'])){
  $ToTime = $_POST['ToTimeHours'];
  }
  if(isset($_POST['ToTimeMins'])){
  $ToTimeMins = $_POST['ToTimeMins'];
  }
  
  $FromDateTime = $FromDate . " " . $FromTime . ":".$FromTimeMins.":00";
  $ToDateTime = $ToDate . " " . $ToTime . ":".$ToTimeMins.":00";
  
      //With the help of Stackoverflow member "scaisEdge" I have the follwong query:
  
  SELECT ClientName, RoomName, RoomFromDateTime, RoomToDateTime FROM Conf
  WHERE HotelID = '".$HotelID."' AND RoomID = '".$RoomID."' AND (RoomFromDateTime
  BETWEEN str_to_date('".$FromDateTime ."', '%Y-%m-%d %T' ) AND str_to_date('".$ToDateTime."',  '%Y-%m-%d %T' 
  OR RoomToDateTime BETWEEN str_to_date('".$FromDateTime ."','%Y-%m-%d %T' ) AND str_to_date('".$ToDateTime."','%Y-%m-%d %T' ))
  </code></pre>
  
  <p>If I hard code the selected user input using the following dates and times, From "2018-09-14 08:00:00", To "2018-09-14 16:00:00"  the query looks like this:</p>
  
  <pre><code>SELECT ClientName, RoomName, RoomFromDateTime, RoomToDateTime FROM Conf
  WHERE HotelID = 'EXBHX' AND RoomID = '3' AND (RoomFromDateTime
  BETWEEN str_to_date('2018-09-15 08:00:00', '%Y-%m-%d %T' ) AND str_to_date('2018-09-15 16:00:00', '%Y-%m-%d %T' )
  OR RoomToDateTime BETWEEN str_to_date('2018-09-15 08:00:00','%Y-%m-%d %T' ) AND str_to_date('2018-09-15 16:00:00','%Y-%m-%d %T' ))
  </code></pre>
  
  <p>Running this query returns 1 record.</p>
  
  <p>However, if I change the "$FromTimeHours" to any hours time less than "16", the query returns zero records.</p>
  
  <p>I have even tried converting all the datetimes into UNIX TimeStamps but the results are the same. Can anyone help me solve this issue.</p>
  
  <p>Many thanks in advance of your time.</p>