Deepak Ranjan Jena
Deepak Ranjan Jena

Reputation: 437

mysql query for date difference

I have a table record where I am storing records of time like this:

login_time
---------------
2010-12-08 13:40:57
2010-12-08 13:28:57
2010-12-08 13:10:57
2010-12-08 12:01:57
2010-12-08 11:05:57

I am using MySQL. I want to write a query to get all records which are less that "15 MINUTES" from current time.

can anyone help me out writting that query?

Upvotes: 1

Views: 987

Answers (1)

Linus Kleen
Linus Kleen

Reputation: 34662

SELECT * FROM `table` WHERE `timestamp` > DATE_SUB(NOW(), INTERVAL 15 MINUTE)

Notice: don't write INTERVAL 15 MINUTES. It has to be MINUTE.

Upvotes: 3

Related Questions