I am trying to get the date of the last week with python.
if date is : 10 OCT 2014 means
It should be print
10 OCT 2014, 09 OCT 2014, 08 OCT 2014, 07 OCT 2014, 06 OCT 2014, 05 OCT 2014, 04 OCT 2014
I tried:
today = (10 OCT 2014)
dates = [today + datetime.timedelta(days=i) for i in range(-4 - today.weekday(), 4 - today.weekday())]
print dates
I am getting this error:
exceptions.AttributeError: 'unicode' object has no attribute 'weekday'
today
variabe? Are you creating it using thedatetime
object like so,datetime.date(2014, 10, 10)
? The error message seems to lead that you are not. – Anthony Forloney