Neal
Neal

Reputation: 463

Comparing two dates in mysql

I have a mysql database table with a column called task_end_date and task_name.

I want to select all the task_name from the table where the current date has passed task_end_date. How would i do that in mysql using an sql query.

Thanks

Upvotes: 0

Views: 7484

Answers (2)

karim79
karim79

Reputation: 342765

SELECT task_name FROM table WHERE curdate() > task_end_date

Note that curdate() as its name implies has no TIME component. If time really isn't important, then curdate() is the way to go, otherwise go with now().

Upvotes: 2

VolkerK
VolkerK

Reputation: 96189

SELECT
  x,y,z
FROM
  foo
WHERE
  task_end_date < Now()

Maybe you want Curdate() instead of Now().

Upvotes: 2

Related Questions