Skip to content

Instantly share code, notes, and snippets.

@jonperron
Created November 15, 2016 13:00
Show Gist options
  • Save jonperron/e74ab46eae5e39cec5e6ea897dc60c4c to your computer and use it in GitHub Desktop.
Save jonperron/e74ab46eae5e39cec5e6ea897dc60c4c to your computer and use it in GitHub Desktop.
Python 2.x month generator, using python-dateutil (https://dateutil.readthedocs.io/)
def monthrange(start_date,end_date):
for n in range(relativedelta(end_date,start_date).years * 12 + relativedelta(end_date,start_date).months + 1):
yield start_date + n*relativedelta(months=1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment