0 points

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


dashboard

Tue Sep 08 2020 09:07:19 GMT+0000 (UTC)

Posted 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_copy Copy

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