This will give you the last month:
WHERE dateColumn BETWEEN SUBDATE(CURDATE(), INTERVAL 1 MONTH) AND NOW();
This is from the beginning of the month:
WHERE dateColumn BETWEEN STR_TO_DATE('2012-09-01', '%Y-%m-%d') AND NOW();
BETWEEN is nothing special, it's just a shortcut to
dateColumn <= ... AND dateColumn >= ....
Hmm, I assume that comparing NOW () is not really required, since all entries will be before that.
So simple:
WHERE dateColumn >= STR_TO_DATE('2012-09-01', '%Y-%m-%d')
Dynamic start of the current month:
WHERE dateColumn >= CURDATE() - INTERVAL DAY(CURDATE())-1 DAY
All this is to extract the day of the month from the current date, and then subtract from it a few days less.
Ariel
source share