Mysql Datevalue()=Date()
Question
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?
Solution
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
OTHER TIPS
You should try WHERE table.date = DATE( -your date- ). For instance:
WHERE table.date = DATE('1977-10-20') ;
your function usage is wrong:
WHERE DATE(table.Date)=CURRENT_DATE
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow