How to check if timestamp is greater than 24 hours from now with mysql?
DELETE FROM `users` WHERE `time` = ?
Update: date format — 2013-10-24 13:33:23
GETDATE() function: This function is used to return the present date and time of the database system. After comparison column contains the following string: Lesser than- If the date is less than today's date. Greater- If the date is greater than today's date.
Can you compare timestamps in SQL? A date, time, or timestamp value can be compared with another value of the same data type, a datetime constant of the same data type, or with a string representation of a value of that data type.
In the above SQL query, we use MySQL system function now() to get current datetime. Then we use INTERVAL clause to select those rows where order_date falls within past 24 hours of present datetime. Instead of specifying interval in hours, you can also mention it in day.
MySQL CURRENT_TIMESTAMP() Function The CURRENT_TIMESTAMP() function returns the current date and time. Note: The date and time is returned as "YYYY-MM-DD HH-MM-SS" (string) or as YYYYMMDDHHMMSS. uuuuuu (numeric).
Try out this Query:
SELECT * FROM news WHERE date >= now() + INTERVAL 1 DAY;
Feel free to ask
try this:
DELETE FROM `users` WHERE `time` >= (NOW() + INTERVAL 1 DAY);
or try this:
DELETE FROM `users` WHERE `time` >= DATE_SUB(CURDATE(),INTERVAL 1 DAY);
or try this:
DELETE FROM `users` WHERE `time` >= curdate() + interval 1 day
here is a link with some function mysql to manage time
DOCUMENTATION
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