Created
April 11, 2013 16:04
-
-
Save tsileo/5364680 to your computer and use it in GitHub Desktop.
Return the last x days from a datetime.date object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dateutil.relativedelta import relativedelta | |
from datetime import date | |
def get_last_x_days(x, date_from=date.today()): | |
for i in xrange(x): | |
date_from += relativedelta(days=i) | |
yield date_from |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment