Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

querying results from mysql in the last 3 hours?

i want to query blog posts from the database created in the last 3 hours,

table

blogs{id,blog_text,date}

date format: datetime

like image 247
getaway Avatar asked Oct 29 '10 02:10

getaway


1 Answers

Try this:

SELECT * FROM blogs WHERE date > DATE_ADD(NOW(), INTERVAL -3 HOUR)

Edit: my bad - replaced CURDATE() with NOW() as we're dealing with DateTimes.

like image 184
mway Avatar answered Nov 15 '22 07:11

mway