2017-02-13 49 views
0

查詢:Laravel whereDate在選擇

$vrec=DB::table('st_sales_live_bk')->where('brandid', $brandid) 
          ->where('branchid', $branchid) 
          ->where('module_id', 1) 
          ->select(DB::raw('trunc(EODATE)')) 
          ->get(); 
return $vrec; 

我使用whereDate在條件TRUNC時間字段,現在我要選擇使用DB ::原料如果可能的話,任何幫助日期時間字段(eodate)?

回答

0

您必須在where條件之前使用DB::raw。您的查詢應該看起來像

$vrec=DB::table('st_sales_live_bk')->select(DB::raw('trunc(EODATE)')) 
       ->where('brandid', $brandid) 
       ->where('branchid', $branchid) 
       ->where('module_id', 1)         
       ->get(); 
return $vrec;