Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysql query where condition with Date not equal to '0000-00-00'

Tags:

mysql

Iam trying to write a mysql query in which the where condition is (WHERE date !='0000-00-00'). But the query is not executing properly.

WHERE date != '0000-00-00'
like image 395
Sanju Menon Avatar asked Feb 06 '23 15:02

Sanju Menon


1 Answers

First cast date to char. then try.

WHERE CAST(`date` AS CHAR(10)) != '0000-00-00'

OR

WHERE `date` != 0

OR

WHERE UNIX_TIMESTAMP(`date`) != 0

OR

WHERE `date` IS NOT NULL

OR

WHERE YEAR(`date`)=0
like image 64
Chandana Kumara Avatar answered Feb 08 '23 16:02

Chandana Kumara