Forum Moderators: coopster
$year = $_REQUEST['year'];
$month = $_REQUEST['month'];
$day = $_REQUEST['day'];
$date = $_REQUEST['date'];
$date = $year."-".$month."-".$day;
SELECT DATE_FORMAT(fecha, '%d-%m-%y') as ffecha, importe, pagado, servicios,DATE_FORMAT(llegada, '%e/%c') as fllegada, DATE_FORMAT(salida, '%e/%c') salida, TO_DAYS(salida) - TO_DAYS(llegada) as dias, propiedades.id_propiedad, cliente FROM propiedades LEFT JOIN bookings ON propiedades.id_reservas = bookings.id AND propiedades.id_propiedad = bookings.propiedad WHERE propiedades.id_propiedad = '$propiedad' and quarter(fecha) = quarter('$date') and year(fecha) = year('$date') order by fechaselect
sum(importe)
- sum(servicios)
-sum(pagado) as total_duenos
from propiedades WHERE propiedades.id_propiedad = '$propiedad' and fecha <= DATE_ADD('$date', INTERVAL -3 MONTH)",$dbh);
The date I get when they choose year and month (month 3, 6, 9 or 12) and the day is a hidden field
<input type="hidden" name="day" size="1" value="31">
The problem is with the value 31 for the days, if the quarter choosen has 30 days instead of 31 I do not get any results anymore....
So One way of fixing could be to take away the hidden day value and in the form choose the month with the day like this 03-31, 06-30 etc...
that works perfect for choosen one quarter, but dont work when I want the balance for previous quarter, though the way of counting previous quarters balance is
using DATE_ADD('$date', INTERVAL -3 MONTH. Doing that takes me to previous quarters balance to day 30 instead of 31 in some cases.... Donīt know how to fix this.
Please help, thanks
Helen
One reason for wrong balance could be that if you supply an incorrect date for DATE_ADD (such as 2007-06-31) it returns null.
I don't know if this helped at all, maybe you could illustrate the problem a bit further.
</ignore>
[edited by: deMorte at 9:28 am (utc) on May 29, 2008]