title: How can i get a value between two date from database?
body: <p>I am creating an application for hotel booking. How can i fetch data between two dates.</p>
  
  <p>Here is my Controller logic.</p>
  
  <pre><code>public function GetMarriageDate(){
  
     $frm = $this-&gt;input-&gt;post('from');
  
     $to = $this-&gt;input-&gt;post('to');
  
     $date=$this-&gt;db-&gt;query("SELECT * FROM `tbl_marriagebooking` WHERE (to_date BETWEEN '$frm' AND $to')UNIONSELECT * FROM `tbl_marriagebooking` WHERE (from_date BETWEEN '$frm' AND to')");
  
     $count=$date-&gt;num_rows();return $count;
  
  }
  </code></pre>
  
  <p>My dataBase <code>table(tbl_marriageBooing)</code></p>
  
  <pre><code>id   name        to_date        from_date
  
  1    name 1     2014-11-15    2014-11-18
  
  2    name 2     2014-11-20    2014-11-24
  
  3    name 3     2014-11-26     2014-11-30   
  </code></pre>
  
  <p>My problem is that if some one selects date <code>to=2014-11-20</code>  from <code>2014-11-23</code> in this condition, sql returns or selects  <code>id = 2</code> because <code>2014-11-20</code> from <code>2014-11-24</code> are  booked.</p>