SQLSTATE[42S22]: Column not found: 1054 Unknown column 'DATE_FORMAT(date,'%d/%m/%Y') AS date_conv
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'DATE_FORMAT(date,'%d/%m/%Y') AS date_conv
Hi Guys,
I can't get round this problem. Whatever I try it gives me the same error. The wired is when I try the query in phpMyAdmin it works.
So I've got:
$table = 'item';
$table2 = 'left join user_profile on item.user_checked_in = user_profile.id';
$columns = array(
array( 'db' => 'item_id', 'dt' => 0 ),
array( 'db' => 'description', 'dt' => 1 ),
array( "db" => "DATE_FORMAT(item.date_in,'%d/%m/%Y') AS date_converted", "dt" => 2 ),
array( 'db' => 'location_found', 'dt' => 3 ),
array( 'db' => 'user_name', 'dt' => 4 ),
array( 'db' => 'returned', 'dt' => 5 )
);
Please help!
Answers
I found the solution. Just for these who struggle like me this is what I did:
$columns = array(
array( 'db' => 'item_id', 'dt' => 0 ),
array( 'db' => 'description', 'dt' => 1 ),
array(
'db' => 'date_in',
'dt' => 2,
'formatter' => function( $d, $row ) {
return date( 'd/m/Y', strtotime($d));
}
),
array( 'db' => 'location_found', 'dt' => 3 ),
array( 'db' => 'user_name', 'dt' => 4 ),
array( 'db' => 'returned', 'dt' => 5 )
);