So I have gathered the following code outputs fine and show me today's date and also the date 10 months ago:
$today = date("Y/m/d");
$months = date("Y/m/d", strtotime("-10 months"));
echo $today; // 2016/03/20
echo "</br>";
echo $months; //2015/05/20
Now I am trying to use the following code. I have a 'date_of_test' column in my DB and I only want it to show pupils tested in the last 10 months. However, I am getting no results even know there are dates in the DB within the last 10 months. If I swap the order of today and months, I only get dates between Jan and now. Any ideas?!
$query = "SELECT * FROM year9_records WHERE date_of_test BETWEEN '$today' AND '$months'";
$result = mysqli_query($conn,$query) or die("Error".mysqli_error($conn));
$row = mysqli_fetch_assoc($result);
$num_rows = mysqli_num_rows($result);
$query = "SELECT * FROM year9_records WHERE date_of_test BETWEEN date_format(date('$today'),'%Y/%m/%d') AND date_format(date('$months'),'%Y/%m/%d') ";