Reputation: 21
Good Morning,
I have the following code
select c.nome
from clientes as c
inner join vencimentos v on c.id = v.id_clientes
where v.data BETWEEN CURDATE() AND CURDATE() + INTERVAL 30 DAY
He brings the records within the 30-day interval, but what I wanted him to return is only the records from the current date plus 30 days, that is, only those records that will expire in 30 days from the current date, not in the interval of 30 days from the current date.
I'm using mysql
Upvotes: 1
Views: 139
Reputation: 1269443
If data
is just a date, use equality:
where v.data = CURDATE() + INTERVAL 30 DAY
If data
has a time component, then use an inequality:
where v.data >= CURDATE() + INTERVAL 30 DAY and
v.data < CURDATE() + INTERVAL 31 DAY and
Upvotes: 2