views:

2807

answers:

2

I have a python datetime.datetime object. What is the best way to subtract one day?

+18  A: 

e.g.

from datetime import date, timedelta

d=date.today()-timedelta(days=days_to_subtract)
Steve B.
+3  A: 

Subtract datetime.timedelta(days=1)

S.Lott