-1
I have some conditions on a page of my system, I need to put something in my SELECT
so that on his own SELECT
has already entered a certain condition.
The condition is as follows, I need these two points to be true:
- If the payment date is equal to 0000-00-00
- If it passed 30 days after the date of issuance, and that "predefined" day is smaller (smaller because it would have already ended the period of 1 month) than today’s date.
One hypothesis of mine was to add + 30 days on payment date and compare with today’s date, but I don’t even know if I can do it in a SELECT
.
SELECT nota_fiscal, emissao, valor, pagamento FROM emissao_nf WHERE pagamento = '0000-00-00'
It is possible to add days to all the dates that are registered and still compare with today’s date, all in one SELECT
?
How can I be doing it this way or even another?
It worked, in this case I didn’t use the
OR
and yes theAND
, needed both conditions, thanks! + 1– Samuel Verissimo
In this case I think your query should be about payment = '0000-00-00' (indicating that there was no payment) AND a check on the issue, or payment deadline. By the question it seemed that both its conditions were on the pay column. @Samuel
– tvdias
Yes,
0000-00-00
indicating that there was no payment and a check on the date of issue. In his reply, I only exchanged theOR
forAND
andemissao + INTERVAL 30 DAY < CURDATE()
– Samuel Verissimo