Finding yesterday's date with datetime

andyrsmith at googlemail.com andyrsmith at googlemail.com
Mon May 15 12:15:29 EDT 2006


Try something like this...

HTH.  A.


from datetime import *

d1 = datetime( year=2006, month=5, day=15)
d2 = datetime.now()

for d in [d1,d2]:
    yest = d - timedelta(days =1 )

    print "%s -> %s" % (d, yest)




More information about the Python-list mailing list