How do I find the previous Monday's date, based off of the current date using Python? I thought maybe I could use:
>>> import datetime >>> today = datetime.date.today() >>> today + datetime.timedelta(days=-today.weekday(), weeks=1) datetime.date(2009, 10, 26)
Some words of explanation:
Take todays date. Subtract the number of days which already passed this week (this gets you 'last' monday). Add one week.
Edit: The above is for 'next monday', but since you were looking for 'last monday' you could use
today - datetime.timedelta(days=today.weekday())