Cita:
Iniciado por quimfv
Código PHP:
Ver originalecho "SELECT DATE_FORMAT(llegada, '%e %b %Y') as lleg, ".
" DATE_FORMAT(salida, '%e %b %Y') as sal,".
" tiporeserva,".
" propiedad,".
" TO_DAYS('".$salida."') - TO_DAYS('".$llegada."') as dias ".
"from bookings ".
"where (propiedad = '".$propiedad."') ".
" AND (('".$llegada."' BETWEEN llegada AND date_sub(salida, interval +1 day)) ".
" or ('".$salida."' BETWEEN date_sub(llegada, interval -1 day) ".
" AND salida) ".
" or (llegada <= '".$llegada."' ".
" AND salida >= '".$salida."') or (llegada >= '".$llegada."' ".
" AND salida <= '".$salida."'))";
o
Código PHP:
Ver originalecho "SELECT DATE_FORMAT(llegada, '%e %b %Y') as lleg,
DATE_FORMAT(salida, '%e %b %Y') as sal,tiporeserva, propiedad,
TO_DAYS('$salida') - TO_DAYS('$llegada') as dias
from bookings where (propiedad = '$propiedad')
AND (('$llegada' BETWEEN llegada AND date_sub(salida, interval +1 day))
or ('$salida' BETWEEN date_sub(llegada, interval -1 day)
AND salida) or (llegada <= '$llegada'
AND salida >= '$salida') or (llegada >= '$llegada'
AND salida <= '$salida'))";
como prefieras.
Gracias,
me imprime:
SELECT DATE_FORMAT(llegada, '%e %b %Y') as lleg, DATE_FORMAT(salida, '%e %b %Y') as sal, tiporeserva, propiedad, TO_DAYS('2012-12-09') - TO_DAYS('2012-12-01') as dias from bookings where (propiedad = 'Casa Test') AND (('2012-12-01' BETWEEN llegada AND date_sub(salida, interval +1 day)) or ('2012-12-09' BETWEEN date_sub(llegada, interval -1 day) AND salida) or (llegada <= '2012-12-01' AND salida >= '2012-12-09') or (llegada >= '2012-12-01' AND salida <= '2012-12-09'))
Me da el valor????