title: changing datetime to date for comparison in codeigniter
body: <p>I have a table with a datetime variable and it talble the values are likewhich has records of the format <code>2015-06-22 22:30:00.030</code>.</p>
  
  <p>How can I cast the datetime to a date format in codeigniter so that i can compare it with a date entered in a form (excluding the time)? This is my query and it gives me this error: </p>
  
  <blockquote>
    <p>You have an error in your SQL syntax; check the manual that
    corresponds to your MySQL server version for the right syntax to use
    near 'As Date) > '%2015/05/31%' AND
    merchant_transactions.CAST(datetime As Date) &lt; '%2' at line 7</p>
  </blockquote>
  
  <pre><code>    $search_where = "merchant_transactions.CAST(datetime As Date) &gt; '%".$from."%' AND merchant_transactions.CAST(datetime As Date) &lt; '%".$to."%'";
  
     $this-&gt;db-&gt;where($search_where);
     return $this-&gt;db-&gt;get();
  </code></pre>