Ant Ant - 2 months ago 6
MySQL Question

Mysql Datevalue()=Date()

I'm trying to split a table in two views depending on whether the field "Date" is today or not.

I have tried using

WHERE DATEVALUE(
table
.
Date
)=DATE()
, but I get an error at saving saying that the last ) has wrong syntax. I tried adding a group by, but apparently everything after the ) gives me the same message about wrong syntax)
Am I typing something wrong? Can I fix this? Is there maybe another way to do this?

Answer

The condition you're looking for is:

table.`Date` = CURDATE()

if you column is of DATE type or

DATE(table.`Date`) = CURDATE()

if it's of DATETIME type

Comments