MySQL Where DateTime大于今天 [英] MySQL Where DateTime is greater than today

查看:405
本文介绍了MySQL Where DateTime大于今天的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



样本:

 去午餐,2014-05-08 12-00-00
去床,2014-05-08 23-00-00

输出应该只有:

 去床,2014-05-08 23-00-00

我使用日期列的DateTime



已经搜索:



您的日期大于一个月?



MySQL日期等于或大于今天的时间



但这对我来说不起作用。



QUERY(FOR PHP):

  SELECT`name`,`date` FROM`tasks` WHERE`tasks`.`datum`> = DATE(NOW()) 

OR(FOR PhpMyAdmin)

  SELECT`name`,`date` FROM`tasks` WHERE`tasks`.`datum`> = 2014-05 -18 15-00-00; 

请帮我编写工作查询。

解决方案

删除 date() part

  SELECT name,datum 
FROM tasks
WHERE datum> = NOW()

如果您使用特定的日期,请勿忘记周围的引号,并使用正确的格式与

  SELECT name,datum 
FROM tasks
WHERE datum> ='2014-05-18 15:00:00'


I want to get evry record from my MySQL database wich is greater than today.

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

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):

SELECT `name`,`date` FROM `tasks` WHERE `tasks`.`datum` >= DATE(NOW())

OR (FOR PhpMyAdmin)

SELECT `name`,`date` FROM `tasks` WHERE `tasks`.`datum` >= 2014-05-18 15-00-00;

Please help me to write the working Query.

解决方案

Remove the date() part

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'

这篇关于MySQL Where DateTime大于今天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆