日期时间大于今天的 MySQL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23722352/
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
MySQL Where DateTime is greater than today
提问by RobDev
I want to get evry record from my MySQL database wich is greater than today.
我想从我的 MySQL 数据库中获取比今天更大的所有记录。
Sample:
样本:
"Go to Lunch","2014-05-08 12-00-00"
"Go to Bed","2014-05-08 23-00-00"
Output should only:
输出应该只:
"Go to Bed","2014-05-08 23-00-00"
I use the DateTime for the Date Column
我使用 DateTime 作为日期列
Already searched:
已经搜索:
MySQL Where date is greater than one month?
Datetime equal or greater than today in MySQL
But this does not work for me.
但这对我不起作用。
QUERY(FOR PHP):
查询(对于 PHP):
SELECT `name`,`date` FROM `tasks` WHERE `tasks`.`datum` >= DATE(NOW())
OR (FOR PhpMyAdmin)
或(对于 PhpMyAdmin)
SELECT `name`,`date` FROM `tasks` WHERE `tasks`.`datum` >= 2014-05-18 15-00-00;
Please help me to write the working Query.
请帮助我编写工作查询。
回答by juergen d
Remove the date()
part
移除date()
零件
SELECT name, datum
FROM tasks
WHERE datum >= NOW()
and if you use a specific date, don't forget the quotes around it and use the proper format with :
如果您使用特定日期,请不要忘记它周围的引号并使用正确的格式 :
SELECT name, datum
FROM tasks
WHERE datum >= '2014-05-18 15:00:00'
回答by echo_Me
I guess you looking for CURDATE()
or NOW()
.
我猜你在找CURDATE()
或NOW()
。
SELECT name, datum
FROM tasks
WHERE datum >= CURDATE()
LooK the rsult of NOW and CURDATE
查看 NOW 和 CURDATE 的结果
NOW() CURDATE()
2008-11-11 12:45:34 2008-11-11
回答by Kodebetter
SELECT *
FROM customer
WHERE joiningdate >= NOW();