Reputation: 3777
I have a column in my table that is called timestamp that is in this format: 2012-05-01 15:33:06
How do I perform a select that only pulls records within the last 15 min? I found this in the PHP manual but am not sure how to modify for 15 minutes? Can someone give me a sample?
WHERE timestamp(CURDATE(),INTERVAL 30 DAY)
Upvotes: 0
Views: 98
Reputation: 6950
try using timestampdiff
TIMESTAMPDIFF(MINUTE,`yourcolumn`,CURDATE()) = 15;
Upvotes: 1
Reputation: 24276
My logic tells me that I should try MINUTE instead of DAY.. did you tried it?
WHERE timestamp(CURDATE(),INTERVAL 15 MINUTE)
Upvotes: 1
Reputation: 4353
Try this............
SELECT * FROM myTable
WHERE COLUMN_NAME >= NOW() - INTERVAL 15 MINUTE
Upvotes: 3
Reputation: 3852
SELECT .. FROM <table_name> Where <field_name> >= (DATE_SUB(now(), INTERVAL 15 MINUTE))
Upvotes: 1