samedi 8 septembre 2018

Using php variable inside raw query laravel

I am trying to get the difference between two dates in Laravel. So i have tried below code.

Laravel Query:

 $currentdate = Carbon\Carbon::now()->setTimezone('America/Vancouver');

 $assigned = DB::table('p_n_rs')->leftjoin('library_updates', 
 'p_n_rs.Request_ID', '=','library_updates.Request_ID')
 ->select('p_n_rs.*','library_updates.Completed_Date', 
 DB::raw('datediff(slaEndDate,$currentdate) as remdays'))
 ->get();

But the result value for remdays is always null. I have also used concatenation operator and seperated php variable and query but still remdays column is null. Help is appreciated.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2QdQE35
via IFTTT

Aucun commentaire:

Enregistrer un commentaire