0
Sections of the table
The intention is to bring the records of the commemorative dates in an interval of month and day.
Example: I want to bring the commemorative dates that are between 15 January and 15 February, but when the filter is from one month to the other no results are returned, but if I enter the filter being the dates from 01 to 15 January, the query returns all satisfactory results
+-----+-----+--------------------------------------------------+
| Mes | Dia | Descricao |
+-----+-----+--------------------------------------------------+
| 01 | 01 | Confraternização Universal |
| 01 | 01 | Dia Mundial da Paz |
| 01 | 02 | Dia da Abreugrafia |
| 01 | 05 | Criação da 1ª Tipografia no Brasil |
| 01 | 06 | Dia de Reis |
| 01 | 06 | Dia da Gratidão |
| 01 | 07 | Dia da Liberdade de Cultos |
| 02 | 01 | Dia do Publicitário |
| 02 | 02 | Dia do Agente Fiscal |
| 02 | 02 | Dia de Iemanjá |
| 02 | 05 | Dia do Datiloscopista |
| 02 | 07 | Dia do Gráfico |
| 02 | 08 | Carnaval |
| 02 | 09 | Cinzas |
| 02 | 09 | Dia do Zelador |
+-----+-----+--------------------------------------------------+
Query
SELECT
Datas_comemorativas.Mes AS Mes,
Datas_comemorativas.Dia AS Dia,
Datas_comemorativas.Evento AS Evento
FROM Datas_comemorativas
WHERE Dia >= '15'
AND Mes >= '01'
AND Dia <= '15'
AND Mes <= '02'
ORDER BY
Mes ASC,
Dia ASC
Ai when it is from January 22nd to 28th she brings the whole month
– Fabricio
@Fabricio In this case, where there is only 1 month, you would have to filter everything with and even. You need a dynamic query where these 2 values are entered by the user?
– Edumelzer
Yes are typed by the user
– Fabricio
I added a new alternative, using string concatenation (since its field is not of the date type). Take a look if it solves your problem
– Edumelzer
Nope, I’m almost doing a dynamic query when it’s the same month I use and when it’s a different month I use or, it’s a lot of Gambi
– Fabricio