n days ago from today.datetime.date.today() to get the current day.datetime.timedelta to subtract n days from today's date.from datetime import timedelta, date def days_ago(n): return date.today() - timedelta(n)
days_ago(5) # date(2020, 10, 23)
Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️