I am trying to count the number of orders that have been made for each restaurant in my db, this month. I was wondering how you would count the number of restaurants based on the month and year.
I have had a attempt:
$mm = date('m');
$yy = date('Y');
$month_sales = mysqli_query($dbc, "SELECT COUNT(Order_ID)FROM ord_dets WHERE
Resturant_ID='$Restaurant_id' AND DATEPART(yyyy,Date_Time_Placed ) ='$yy' AND DATEPART(mm,OrderDate)='$mm'");
$month_sales_row = $month_sales->fetch_row();
printf("%d \n", $month_sales_row);
Uncaught mysqli_sql_exception: FUNCTION one_delivery.DATEPART does not exist in..
SELECT COUNT(Order_ID) FROM ord_dets WHERE Resturant_ID='$Restaurant_id' AND YEAR(Date_Time_Placed) = '$yy' AND MONTH(OrderDate) = '$mm'
If your dates are UNIX timestamps you will need to convert them first with
Hope this helps :)