SQL 检查时间戳是否大于 24 小时(MYSQL)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19605140/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SQL check if timestamp is greater than 24 hours from now (MYSQL)
提问by 10minutee
How to check if timestamp is greater than 24 hours from now with mysql?
如何使用mysql检查时间戳是否大于24小时?
DELETE FROM `users` WHERE `time` = ?
Update: date format — 2013-10-24 13:33:23
更新:日期格式 — 2013-10-24 13:33:23
回答by Gauttam Jada
Try out this Query:
试试这个查询:
SELECT * FROM news WHERE date >= now() + INTERVAL 1 DAY;
Feel free to ask
随意问
回答by Alessandro Minoccheri
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
这是一个带有一些功能 mysql 的链接来管理时间
文档
回答by Bjoern
You might want to try this:
你可能想试试这个:
DELETE FROM `users`
WHERE `time` >= TIMESTAMPADD(DAY, 1, NOW());
NOW()
returns the current date and time.
NOW()
返回当前日期和时间。
TIMESTAMPADD(unit,interval_expression)
adds one day to the current date and time.
TIMESTAMPADD(unit,interval_expression)
在当前日期和时间上增加一天。