Finding yesterday's date with datetime
Michael J. Fromberger
Michael.J.Fromberger at Clothing.Dartmouth.EDU
Mon May 15 12:14:13 EDT 2006
In article <1147709343.491705.276360 at v46g2000cwv.googlegroups.com>,
"Thierry Lam" <lamthierry at gmail.com> 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 = datetime.today()
yesterday = today - timedelta(1)
# See the .month, .day, and .year fields of yesterday
Cheers,
-M
--
Michael J. Fromberger | Lecturer, Dept. of Computer Science
http://www.dartmouth.edu/~sting/ | Dartmouth College, Hanover, NH, USA
More information about the Python-list
mailing list