본문 바로가기
MySql

MySQL 라 라벨 단순 월 선택

by 베이스 공부 2020. 12. 2.
반응형

y SQL 절 MONTH로 테스트가 작동하지 않는 날짜 필드 "fechas"(datetime 유형)에서 월 검색을 시도했습니다 ... 회신 주셔서 감사합니다

            $data = DB::table("ordenes")
              ->select(array('*', DB::raw('((cant_ped)*(precio_unit)) as sum_pedidos'), DB::raw('((cant_pend)*(precio_unit)) as sum_pends'), DB::raw('((cant_rec)*(precio_unit)) as sum_recibidos'), DB::raw('(((cant_pend)*(precio_unit)) + ((cant_rec)*(precio_unit))) as sum_importe')))
              ->where('cod_prov', '<>', 0)

              ///////////// line ERROR
              ->where('MONTH(fecha)', '=', '06')

              ///////->where('MONTH(fecha)', '=', '2014-06-20') ///test OK

              ->groupBy('cod_prov')
              ->skip(Input::get("jtStartIndex"))
              ->take(Input::get("jtPageSize"))
              ->get();

 

해결 방법

 

hide gem whereMonth 를 사용할 수 있습니다.

DB::table("ordenes")
    ->whereMonth('fecha', '=', '06')
    ->get();

다른 gem을 검색하려면 Builder.php 소스를 읽어 보시기 바랍니다. :)


 

참조 페이지 https://stackoverflow.com/questions/25173471

 

 

반응형

댓글