how can i group my grid by month?
each row has a date (yyyy-mm-dd) inside, so i thought to calc a field by change the format to yyyy-mm and group the grid by this field, but the group is still the data of each day.
any idea?
(use paid version!)
2 Answers
Hi,
Internally, database sorting is done before group any field. So If you field is calculated one it would throw error.
Solution would be to do the date formatting work in sql select_command so that it is available in sort query.
e.g.
$g->select_command = "SELECT i.id, invdate, date_format(invdate,'%Y/%m') as month , c.name,
i.note, i.total, i.closed FROM invheader i
INNER JOIN clients c ON c.client_id = i.client_id";
Your Answer