title: Select month from a date field in laravel
body: <p>I'm trying to perform a query in Laravel 7 that gets the month part of a date field. I tried the following queries</p>
  <pre><code>$test = MyModal::selectRaw('month(&quot;date_col&quot;) as temp')-&gt;get();
  $test = MyModal::select(DB::Raw('month(&quot;date_col&quot;) as temp'))-&gt;get();
  $test = DB::table('my_table')-&gt;select('month(&quot;date_col&quot;) as temp')-&gt;get();
  </code></pre>
  <p>All variation of the same query. If I dump the query log, the query is correct for all 3</p>
  <pre><code>select month(&quot;date_col&quot;) as temp from &quot;my_table&quot;
  </code></pre>
  <p>If I run this on my DB I get the result as well. But I keep getting this error in laravel:</p>
  <p>Illuminate\Database\QueryException: SQLSTATE[HY000]: General error: 1 no such function: month (SQL: select month(&quot;date_col&quot;) as temp from &quot;my_table&quot;)</p>
  <p>Am I doing something wrong? And is there a way to do this query in laravel?</p>
  <p>Edit: Sorry forgot to mention this is with Laravel's unit testing</p>