Datetime equal or greater than today in MySQL
What's the best way to do following:
SELECT * FROM users WHERE created >= today;
Note: created is a datetime field.
Solution 1:
SELECT * FROM users WHERE created >= CURDATE();
But I think you mean created < today
Solution 2:
SELECT * FROM myTable WHERE DATE(myDate) = DATE(NOW())
Read more: http://www.tomjepson.co.uk/tutorials/36/mysql-select-where-date-today.html
Solution 3:
SELECT * FROM users WHERE created >= NOW();
if the column is datetime type.
Solution 4:
Answer marked is misleading. The question stated is DateTime
, but stated what was needed was just CURDATE()
.
The shortest and correct answer to this is:
SELECT * FROM users WHERE created >= CURRENT_TIMESTAMP;