Date Minor and Greater than X days MySQL [duplicate]

0

I have a field in the table named registro_data_instalacao of type date , I need to display the records with registro_data_instalacao where the date is greater than 3 days and less than 30 days, below, but to no avail.

SELECT *
FROM registro
WHERE registro_data_instalacao >= (CURRENT_DATE() + INTERVAL 3 DAY)
  AND registro_data_instalacao <= (CURRENT_DATE() + INTERVAL 30 DAY) 
    
asked by anonymous 08.05.2018 / 16:31

1 answer

1

You can use DATE_SUB as below;

SELECT *
FROM registro
WHERE v.date > (DATE_SUB(CURDATE(), INTERVAL 3 DAY))
  AND v.date < (DATE_SUB(CURDATE(), INTERVAL 30 DAY))
    
08.05.2018 / 16:48