i want to query blog posts from the database created in the last 3 hours,
table
blogs{id,blog_text,date}
date format: datetime
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 DateTime
s.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With