SELECT COUNT(CODIGO) AS COD
FROM TABLA WHERE DIA = diaAbuscar
AND ((HORAINICIO < horainicio AND HORAFINAL > horainicio )
OR (HORAINICIO < horafin AND HORAFINAL > horafin )
OR (HORAINICIO > horainicio AND HORAINICIO < horafin )
OR (HORAFINAL > horainicio AND HORAFINAL < horafin ))
|