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

Asked

Viewed 1,092 times

0

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

1 answer

3

Use the BETWEEN with date_sub to subtract an interval from the date reported:

SELECT * FROM table WHERE data BETWEEN NOW() AND DATE_SUB(NOW(), INTERVAL 2 YEAR);

Browser other questions tagged

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