MySQL Forums
Forum List  »  Spanish

Re: Consulta para calendario de citas
Posted by: Jesús Uzcanga
Date: April 19, 2013 12:41PM

Roberto.

Lo primero que debes hacer es modificar la tabla para indicar cuál es el día recurrente...

En el caso del tercer registro dices que es cada martes pero no lo específicas en ningún campo... Entonces debes crear un campo llamado "diasemana" que contendrá valores del 1 al 7 donde 0=Lunes y 7=Domingo...

Crear el campo diasemana:
ALTER TABLE `anotaciones` ADD `diasemana` INT(1) UNSIGNED NOT NULL




Luego el query para contar la cantidad de coincidencias es el siguiente:
NOTA: La variable que debe pedir el formulario de tu sistema será la fecha de consulta. Para este ejemplo es = '2013-04-16'

SELECT COUNT(*) FROM anotaciones
WHERE
IF (repetir=1
,
'2013-04-16' BETWEEN fecha_ini AND fecha_fin AND WEEKDAY('2013-04-16')=diasemana
,
'2013-04-16' BETWEEN fecha_ini AND fecha_fin
)

Creo que esto te debería ayudar.

___________________________
Ing. Jesús Alfredo Uzcanga
Twitter: @JesusUzcanga

We learn the 20% of what we HEAR,
the 50% of what we SEE,
the 80% of what we DO and
the 95% of what we TEACH.

____________________________________________________________
https://www.linkedin.com/in/jauzcanga/

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Consulta para calendario de citas
1415
April 19, 2013 12:41PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.