Finding yesterday's date with datetime

Michael J. Fromberger Michael.J.Fromberger at Clothing.Dartmouth.EDU
Mon May 15 18:14:13 CEST 2006

In article <1147709343.491705.276360 at>,
 "Thierry Lam" <lamthierry at> wrote:

> Is there an easy way to determine the yesterday's date(year-month-day)
> from the python datetime library if I know today's date?

from datetime import datetime, timedelta

today =
yesterday = today - timedelta(1)

# See the .month, .day, and .year fields of yesterday


Michael J. Fromberger             | Lecturer, Dept. of Computer Science  | Dartmouth College, Hanover, NH, USA

More information about the Python-list mailing list