import datetime
import dateutil.relativedelta
d = datetime.datetime.strptime('2013-03-31', '%Y-%m-%d')
d2 = d - dateutil.relativedelta.relativedelta(months=1)
print(d2)
What's the simplest way to subtract a month from a date in Python?