Search with date in Laravel

0

I have the following query:

asked by anonymous 02.10.2018 / 20:19

1 answer

1

Try using binding:

DB:RAW('SELECT SUM(N.primeiro_turno + N.segundo_turno + N.terceiro_turno)
      ,SUB.* 
  FROM notes N, (SELECT SUM(NS.total_dia) AS TOTAL_DIA
                       ,NS.sequencing_id 
                   FROM notes NS 
                  WHERE NS.sequencing_id IN (SELECT NT.sequencing_id 
                                               FROM notes NT 
                                              WHERE NT.data_apontamento = DATE_FORMAT(?,"%Y-%m-%d") 
                                              GROUP BY NT.sequencing_id) 
                  GROUP BY NS.sequencing_id) AS SUB 
  INNER JOIN sequencings ON sequencing_id          = sequencings.id 
  INNER JOIN products    ON sequencings.product_id = products.id 
  INNER JOIN machines    ON sequencings.machine_id = machines.id 
  WHERE N.data_apontamento = DATE_FORMAT(?,"%Y-%m-%d") 
    AND N.sequencing_id    = SUB.sequencing_id 
  GROUP BY N.sequencing_id, SUB.sequencing_id, SUB.TOTAL_DIA', [$data1, $data2]);
    
02.10.2018 / 21:00