I was looking for a simple function to get the week of the month (rather than the easy week of the year) in a mysql query.
The best I could come up with was:
My solution with a week starts on a Sunday.
SELECT ( 1 + ((DATE_FORMAT( DATE_ADD(LAST_DAY( DATE_ADD('2014-07-17', INTERVAL -1 MONTH)), INTERVAL 1 DAY),'%w')+1) + (DATE_FORMAT('2014-07-17', '%d')-2) ) DIV 7) "week_of_month";