user3649738 user3649738 - 2 months ago 10
MySQL Question

MySQL Where DateTime is greater than today

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


"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.


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'