I want to make a MySQL selection where the difference between NOW() and a timestamp in the table is less than a specific period of time, like 24 hours. I've tried doing subtraction but it hasn't worked and DateDiff isn't what I want. There must be a simple way to do this, but I can't figure it out. Any ideas?
Thanks
SELECT
timestampdiff(HOUR, yourtimestampcolumn, now() ) as hours_since,
*
FROM
Your_table
WHERE
timestampdiff(HOUR, yourtimestampcolumn, now() ) < 24
Refer https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_timestampdiff
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