Source Code:
(back to article)
from datetime import datetime, timedelta # Define a date date = datetime(2022, 1, 1) # Subtract one day from the date subtracted_date = date - timedelta(days=1) print(subtracted_date) # Output: 2021-12-31 00:00:00
Result:
Report an issue