Ethan Allen
Ethan Allen

Reputation: 14835

How do I find record older than 90 days from a DATETIME field in MySQL?

I have a field called lastlogin in my MySQL database. It holds DATETIME in this format: 2014-04-02 11:03:23

What is the query to call to get all records older than 90 day from today?

Upvotes: 0

Views: 10966

Answers (1)

ooo
ooo

Reputation: 1627

You can do it as so:

SELECT * FROM table
WHERE lastLogin < DATE_SUB(NOW(), INTERVAL 90 DAY);

Upvotes: 15

Related Questions