Date type

Dan Bishop danb_83 at yahoo.com
Fri May 16 15:11:19 EDT 2003


"Batista, Facundo" <FBatista at uniFON.com.ar> wrote in message news:<mailman.1053095964.23749.python-list at python.org>...
> I need a "date type" and I can t find it anywhere.
> 
> With date type I mean something like:
> 
> > a = Date()
> > a.month = 5
> > a.day = 15
> >
> > b = Date()
> > a.month = 5
> > b.day = 17
> >
> > print b-a
>  2
> > print a+1
> Fri May 16 00:00:00 GMT 2003
> 
> There is something like this already?

In Python 2.3, you can do

import datetime
currentYear = datetime.date.today().year
a = datetime.date(currentYear, 5, 15)
b = datetime.date(currentYear, 5, 17)
print (b - a).days
print a + datetime.timedelta(days=1)




More information about the Python-list mailing list