doug shawhan wrote:
> I've been looking at datetime and cannot figure out what was a very 
> simple operation with the time module.
> 
> How does one add or subtract 24 (or any number) of hours from a given 
> date and time using the datetime module?

Use a datetime.timedelta:

In [1]: import datetime

In [2]: now = datetime.datetime.now()

In [3]: now
Out[3]: datetime.datetime(2006, 6, 12, 16, 7, 47, 69000)

In [4]: one_day = datetime.timedelta(hours=24)

In [5]: now-one_day
Out[5]: datetime.datetime(2006, 6, 11, 16, 7, 47, 69000)

Kent

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to