$data['visitors'] = DB::query( "SELECT `institution` , COUNT( `visitor_id` ) AS `jml` FROM `visitor_count` WHERE `checkin_date` >= $startdate AND `checkin_date` <= $enddate GROUP BY `institution` ORDER BY `jml` DESC ")->as_object()->execute();
Enable the profiler in the config, enable database profiling in your db config, and check what SQL is generated, and how it differs from what you typed in manually.