phpmysqlkohanaquery-builderkohana-orm

Date Format conversion return "null" in Kohana query builder


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();

Solution

  • 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();