cghrmauritius
cghrmauritius

Reputation: 177

MySQL group by custom month

Hi I'm wondering if someone can help point me in the right direction.

I'm aware of how to do a group by clause group by DATE_FORMAT(r_date, '%Y %m'); when its the standard calendar month, but how do we do a group by clause when the clients month runs from the 26th to the 25th of each month.

Upvotes: 0

Views: 80

Answers (1)

Volkan Ulukut
Volkan Ulukut

Reputation: 4228

you can use DATE_SUB to normalize the month and group by that value:

...GROUP BY DATE_FORMAT(DATE_SUB(r_date, INTERVAL 25 DAY), '%Y %m');

Upvotes: 1

Related Questions