from math import ceil

def week_of_month(dt):
    """ Returns the week of the month for the specified date.
    """
first_day = dt.replace(day=1)
dom = dt.day
adjusted_dom = dom + first_day.weekday()
return int(ceil(adjusted_dom / 7.0))
python - Week number of the month