I am looking into using datetime to find the date one week before now()... I was wondering if there was a way to use algebraic calculations directly with datetime format?
This is the code I am using.
import datetime
def get_week():
year = datetime.date.today().year
month = datetime.date.today().month
day = datetime.date.today().day
month1 = month
year1 = year
day1 = day-7
if day < 7:
day1 = 26 # In my case, this date back is plenty enough
if month == 1:
month1 = 12
year1 = year-1
return year1, month1, day1, year, month, day