title: Compare two dates in Codeigniter and MySQL
body: <p>How can I get values between two dates in Codeigniter query function? Here is my model and sample code.</p>
  
  <pre><code>function get_promo() {
      $today = date('Y-m-d');
      $query = $this-&gt;db-&gt;query('SELECT FROM tbl_event WHERE event_id = $id AND event_startdate &lt;= $today
      AND event_enddate &gt;= $today');
      return $query;
  }
  </code></pre>
  
  <p>But it doesn't work, here is the error I got</p>
  
  <pre><code>A Database Error Occurred
  
  Error Number: 1064
  
  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 'FROM tbl_event WHERE event_id = 36 AND event_startdate &lt;= 2011-06-09 ' at line 1
  
  SELECT FROM tbl_event WHERE event_id = 36 AND event_startdate &lt;= 2011-06-09 AND event_enddate &gt;= 2011-06-09
  
  Filename: C:\xampp\htdocs\hotel\system\database\DB_driver.php
  
  Line Number: 330
  </code></pre>