How to get the current date minus two years in mysql?

0

I need to show in a query some items between the current date of the time in question and two years before.

    
asked by anonymous 10.05.2017 / 20:38

1 answer

2

Use BETWEEN with date_sub to subtract a range from the entered date:

SELECT * FROM table WHERE data BETWEEN NOW() AND DATE_SUB(NOW(), INTERVAL 2 YEAR);
    
10.05.2017 / 20:43