grouping by a calc field or month/year

Questionsgrouping by a calc field or month/year
Wolfgang asked 8 years ago

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
Abu Ghufran answered 8 years ago

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";

http://pastebin.com/223raqUF

Wolfgang answered 8 years ago

thank you

Your Answer

8 + 8 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?