[Tutor] How Compute # of Days between Two Dates?

greg whittier greg at thewhittiers.com
Mon Sep 1 16:41:30 CEST 2008

On Mon, Sep 1, 2008 at 10:17 AM, Wayne Watson
<sierra_mtnview at sbcglobal.net> wrote:
> That's the question in Subject. For example, the difference between
> 08/29/2008 and 09/03/2008 is +5. The difference between 02/28/2008 and
> 03/03/2008 is 4, leap year--extra day in Feb. I'm really only interested in
> years between, say, 1990 and 2050. In other words not some really strange
> period of time well outside our current era of history.

You want the datetime module.

>>> from datetime import datetime
>>> datetime(2008,03,03) - datetime(2008,2,28)

More information about the Tutor mailing list