Date Format conversion return "null" in Kohana query builder

147 Views Asked by At

Am using kohana query builder to change the cancelled Date format but it return as null value.

Query

$result = DB::select('log_id',array(DB::expr("DATE_FORMAT('cancelled_date', '%Y-%m-%d %h:%i %p')"),'cancelled_date'),'drop_location')
    ->from(TBL_NAME)
    ->where('driver_id','=','15')
    ->execute()->as_array();
1

There are 1 best solutions below

0
Siva On BEST ANSWER

Remove the single quote for "cancelled_date" and its working fine.

$result = DB::select('log_id',array(DB::expr("DATE_FORMAT(cancelled_date, '%Y-%m-%d %h:%i %p')"),'cancelled_date'),'drop_location')
->from(TBL_NAME)
->where('driver_id','=','15')
->execute()->as_array();