python subtract month from date
# Normally deltatime is one of good way to manipulate date and time
# with fine details, but since a month can have different nubmer a days
# relativedelta is a good option;
from datetime import datetime
from dateutil.relativedelta import relativedelta
# Take a timestamps
datetime_now = datetime.now()
print("Current Date and time :- ", datetime_now)
>>> Current Date and time :- 2021-08-16 11:59:49.802902
# Create a delta time
datetime_delta = relativedelta(months=+1)
# subtract datetime_delta
datetime_new = datetime_now - datetime_delta
print("Current Date and time minus Delta datetime :- ", datetime_new)
>>> Current Date and time minus Delta datetime :- 2021-07-16 11:59:49.802902