Rocco The Taco
Rocco The Taco

Reputation: 3777

MySQL timestamp SELECT

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

Answers (4)

alwaysLearn
alwaysLearn

Reputation: 6950

try using timestampdiff

TIMESTAMPDIFF(MINUTE,`yourcolumn`,CURDATE()) = 15;

Upvotes: 1

Mihai Matei
Mihai Matei

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

Ravindra Shekhawat
Ravindra Shekhawat

Reputation: 4353

Try this............

SELECT * FROM myTable
WHERE COLUMN_NAME >= NOW() - INTERVAL 15 MINUTE

Upvotes: 3

Suhel Meman
Suhel Meman

Reputation: 3852

SELECT .. FROM <table_name> Where <field_name> >= (DATE_SUB(now(), INTERVAL 15 MINUTE))

Upvotes: 1

Related Questions