Oct-10-2020, 03:35 AM
strftime() turns it into a string. Do that only at the end, not before the math is done.
from datetime import datetime, timedelta N = 2 date_N_days_ago = datetime.now() - timedelta(days=N) print(datetime.now()) print(date_N_days_ago) print(date_N_days_ago.strftime("%Y-%m-%d 07:20:00"))
Output:2020-10-09 20:34:03.536442
2020-10-07 20:34:03.536418
2020-10-07 07:20:00