im using $orderdate = date('Y-m-d H:i:s'); to store in MySQL datetime
but when retrieving sales report which has a form of
$initialstartdate = $_POST['startdate'];
$initialenddate = $_POST['enddate'];
$startdate = " '$initialstartdate' ";
$enddate = " '$initialenddate' ";
$sql="SELECT * FROM orders
left join order_item on orders.order_id=order_item.order_id
left join products on products.product_id=order_item.product_id
left join category on products.category_id=category.category_id
where orders.order_date BETWEEN $startdate and $enddate;";
it is not showing dates and BETWEEN is not inclusive
maybe there is a problem regarding H:i:s
because it was working properly before changing this $orderdate = date('Y-m-d'); to this $orderdate = date('Y-m-d H:i:s');
i tried concatenating .'00:00:00' to $startdate and $enddate but it didnt work
$startdate = " '$initialstartdate' ";and$enddate = " '$initialenddate' ";is attempting to fix.Betweenis not inclusive. So 2020-07-28 - 2020-07-28 will show no results, 2020-07-28 - 2020-07-29 will only show results for 2020-07-28. To make it inclusive, you have to pass in the timestamp for beginning and ending of the days -- 2020-07-28:00:00:00 - 2020-07-28:23:59:59 will give all of the results for the 28th, 2020-07-29:23:59:59 as the end date will give results for the 28th and 29th