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()[0];
printf("%d \n", $month_sales_row);
mysqli_free_result($month_sales);
But i am getting this error:
Uncaught mysqli_sql_exception: FUNCTION one_delivery.DATEPART does not exist in..
Date_Time_Placed is the column in my table that holds the timestamp for my order.
I am using php 7