Am I asking too much from datetime?

Brian Quinlan brian at sweetapp.com
Tue Jun 1 14:55:29 CEST 2004


>>>>yesterday = datetime.date(today.year, today.month, today.day-1)

> Is this is a bug, or outside of the functionality of datetime?

Try writing it like this:

 >>> import datetime
 >>> today = datetime.date.today()
 >>> print today
2004-06-01
 >>> yesterday = today - datetime.timedelta(days=1)
 >>> print yesterday
2004-05-31

Cheers,
Brian




More information about the Python-list mailing list