I have the well executed postgres query.I have tried to convert this in laravel
but query not executed
select
id,
month,
meeting_start_date,
call_start_date
from mgl_report_targets
where extract(
Month from to_date(mgl_report_targets.month, '%Month-%YYYY')
)
in (
extract(MONTH from meeting_start_date), extract(MONTH from call_start_date)
);
try 1
$db = DB::table('mgl_report_targets as t');
$db = $db->where(function ($query) {
return $query->whereIn(DB::Raw("extract(MONTH from meeting_start_date)"), DB::Raw("extract(Month from to_date('t.month', %Month-%YYYY))"))
->orWhereIn(DB::Raw("extract(MONTH from call_start_date)"), DB::Raw("extract(Month from to_date('t.month', %Month-%YYYY))"));
})
->select('id','month','meeting_start_date','call_start_date')->get();
But no luck.getting Parse error: syntax error, unexpected '}', expecting ';'
Try 2
$db = DB::table('mgl_report_targets as t')
->where(DB::Raw("extract(Month from to_date(mgl_report_targets.month, '%Month-%YYYY')) in (extract(MONTH from meeting_start_date), extract(MONTH from call_start_date))"))
->select('id','month','meeting_start_date','call_start_date')
->get();
Nothing return from my try 2
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire