I'm doing a query between dates, where I want to show the average value, but from the day before the chosen one, I have the following code:
$desde = $_POST['desde'];
$hasta = $_POST['hasta'];
$estacion=2;
$registro = ("SELECT AVG(TS) as TsueloProm1
FROM sensores
WHERE date BETWEEN '$desde'
AND '$hasta'
AND date=date(date(now())-1)
AND idestacion='$estacion' ");
$resultado = $conexion->query($registro);
so for example: when I choose the date '$ from' (02-11-2017) and '$ until' (05-11-2017), in the variable '$ from' I should choose the day before the one chosen, I mean (01-11-2017), and with that query you throw me error, please if you can help me with that.