How can I get the first and last day of next month to be used in the where clause?
In postgresql you have perfect date truncation functions.
For MySQL, I found a discussion here which might give some ideas.