how to compare DateTime Column with Only Date not time
datetime, mysql
Solution
there is a mysql function called DATE which extract the date part of a date or datetime expression
AND DATE(`date`)='$today'
edit: be carefull, as said in the comments below, using this will bypass index on datetime field. You should use instead :
AND date BETWEEN '$today 00:00:00' AND '$today 23:59:59'
Problem
I am using mySql and my table column `date` is DATETIME type But i want to compare only today's date not time ``` $today = date("Y-m-d", time()); ``` IF i compare date using above method it always come wrong. ``` $this->update(" UPDATE `stats_tracker` SET `user_agent`='$this->visitor_user_agent' , `referrer`='$this->referrer_page' , `page_views`='$page_views' WHERE `visitor_ip`='$this->visitor_ip' AND `page`='$this->this_page' AND `date`='$today'"); ``` Please Help me i am not a good mySQL programmer.