Problem with Where

Asked

Viewed 46 times

1

I’m using Mariadb and I have a clause problem WHERE bank.

The query is inside Excel that brings me database periods through the month filter. But I was asked to change it to a time period, only it’s bringing me an empty table and I can’t understand why.

FROM
perfilacoes_table
WHERE
fila_atendimento regexp "DENTALUNIGRC" and
month( date_format(STR_TO_DATE(perfilacoes_table.data_inicio_chamada, '%d/%m/%Y'), '%Y-%m-%d') ) > month( DATE_ADD(date_format(curdate(), '%Y-%m-%d'), INTERVAL -1 DAY) ) -1 and
month( date_format(STR_TO_DATE(perfilacoes_table.data_inicio_chamada, '%d/%m/%Y'), '%Y-%m-%d') ) <= month( DATE_ADD(date_format(curdate(), '%Y-%m-%d'), INTERVAL -1 DAY) ) and
date_format(STR_TO_DATE(perfilacoes_table.data_inicio_chamada, '%d/%m/%Y'), '%Y-%m-%d') < DATE_ADD(date_format(curdate(), '%Y-%m-%d'), INTERVAL 0 DAY)
ORDER BY
date_format(STR_TO_DATE(data_inicio_chamada, '%d/%m/%Y'), '%Y/%m/%d') desc;

This version brings me information, but I need to change it so I changed to:

FROM
perfilacoes_table
WHERE
fila_atendimento regexp "DENTALUNIGRC" and
perfilacoes_table.data_inicio_chamada BETWEEN CAST('2018-12-01' AS DATE) AND CAST('2018-12-31' AS DATE)
ORDER BY
date_format(STR_TO_DATE(data_inicio_chamada, '%d/%m/%Y'), '%Y/%m/%d') desc;

But it brings me an empty table.

There are other querys that I did the same procedure and worked correctly.

I do not understand why in one brings values and in another does not.

  • Recalling that in the case that brings results I am running the same now during the month of December, ie, is returning me the data referring to December. The same way I’m using the BETWEEN December dates.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.