What's the simplest way to subtract a month from a date in Python? - Stack Overflow

PHOTO EMBED

Tue Sep 08 2020 09:07:19 GMT+0000 (Coordinated Universal Time)

Saved by @arielvol #python

import datetime
import dateutil.relativedelta

d = datetime.datetime.strptime("2013-03-31", "%Y-%m-%d")
d2 = d - dateutil.relativedelta.relativedelta(months=1)
print d2
content_copyCOPY

https://stackoverflow.com/questions/3424899/whats-the-simplest-way-to-subtract-a-month-from-a-date-in-python