gistlib
Here's one way to get the date 5 days ago using datetime and timedelta:
datetime
timedelta
main.pyfrom datetime import datetime, timedelta today = datetime.now().date() five_days_ago = today - timedelta(days=5) print(five_days_ago) 136 chars7 lines
from datetime import datetime, timedelta today = datetime.now().date() five_days_ago = today - timedelta(days=5) print(five_days_ago)
Alternatively, you could use dateutil to calculate a relative date:
dateutil
main.pyfrom datetime import datetime from dateutil.relativedelta import relativedelta five_days_ago = datetime.now().date() - relativedelta(days=5) print(five_days_ago) 164 chars7 lines
from datetime import datetime from dateutil.relativedelta import relativedelta five_days_ago = datetime.now().date() - relativedelta(days=5) print(five_days_ago)
gistlibby LogSnag