следующая функция возвращает последнюю дату из нескольких дат
$userid = $this->session->userdata['userId'];
$type = "meeting";
$currentdate = date("Y-m-d H:i:s");
$this->db->select('DATE(date) as date');
$this->db->from('tbl_meetings');
//if user is admin want the latest date from all dates in the respected table
if ($userid!='1') {
$where = "tbl_meetings.date > = ".$currentdate. "AND tbl_inbox.type='meeting'";
$this->db->join('tbl_inbox as t2', 't2.meetingid = tbl_meetings.id','left');
// the following query to get latest date from all dates which that per ticular user(not admin) allocated meetings
} else {
$this->db->where('date >', $currentdate);
}
$this->db->order_by('ABS(DATEDIFF(date, NOW()))', 'ASC');
$this->db->limit(1);
$query = $this->db->get();
$result=$query->result();
return $result;
ORDER BY ABS(DATEDIFF(date, NOW())) ASC LIMIT 1 возвращает дату, ближайшую к настоящему времени. Это не то же самое, что последняя дата из нескольких дат.






Вы можете использовать функцию sql MAX. Пример - SELECT MAX(date) FROM table;
какой здесь вопрос?