title: Laravel 4.2: How to convert raw query to Eloquent
body: <p>I have a raw query which works fine.</p>
  
  <pre><code>$qry ="select date(created_at) as Date,count(id) as Value from performances where date_format(created_at,'%d-%m-%Y') &gt;= '$start_date' and date_format(created_at,'%d-%m-%Y') &lt;= '$to_date' group by Date order by Date desc ";
      $stats = DB::select( DB::raw($qry) );
      return json_encode($stats);
  </code></pre>
  
  <p>I would like to convert it in to Eloquent</p>
  
  <p>My controller function is</p>
  
  <pre><code>public function postPerformanceDetails()
  {
  $start_date = Input::get('start_date');
  $to_date = Input::get('to_date');
  $start_date = date('Y-m-d',strtotime($start_date));
  $to_date = date('Y-m-d',strtotime($to_date));
  $stats = Performance::where('created_at', '&gt;=', $start_date)
          -&gt;where('created_at','&lt;=',$to_date)
          -&gt;groupBy('perf_date')
          -&gt;orderBy('perf_date', 'DESC')
          -&gt;remember(60)
          -&gt;get([
          DB::raw('Date(created_at) as perf_date'),
          DB::raw('COUNT(id) as perf_count')
          ])
          -&gt;toJSON();
  return $stats
  }
  </code></pre>
  
  <p>The raw query works fine but eloquent does not work according to the date input.</p>
  
  <p>I input data in this format 09-03-2015
  in database the format is 2015-03-09</p>
  
  <p>If we give 2015-03-09 as start_date and to_date it returns empty string.</p>
  
  <p>Is there any problem with formats?
  How can i solve this issue?</p>