I am Trying to fetch Data between two dates, date was stored as DATETIME in mysql and showing as 2016-04-02 04:55:03
to get dates I am using bootstrap datetimepicker with input form like below
<div class="input-group date" id="datetimepicker1">
<input type="text" class="form-control" id="checkin" name="from_date" data-date-format="dd/mm/yyyy" placeholder="Select Start Date">
<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
</div>
<div class="gap-small"></div>
<div class="input-group date">
<input type="text" class="form-control datechange" id="checkout" name="to_date" data-date-format="dd/mm/yyyy" placeholder="Select End Date">
<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
</div>
and i am using AJAX to send these values to PHP.
in result page:
var_dump($_POST)
result:
array(3) { ["from_date"]=> string(10) "30/03/2016" ["to_date"]=> string(10) "05/04/2016" ["search_place"]=> array(1) { [0]=> string(0) "" } }
i am getting values in from_date and to_date
now when i am trying to retrive between from and to dates its not working below is my sql statement
$sql="SELECT * FROM mytable WHERE evedate BETWEEN '" . $from_date . "' AND '" . $to_date . "'";