import datetime

today = datetime.date.today()
yesterday = today - datetime.timedelta(1)

x = 5
x_days_ago = today - datetime.timedelta(x)