RLV wrote:
I'd like to find a simple... (I'm a simple person) procedure to
subtract a numerical number from a six char date string YYYYMMDD and then convert back to a new date string.

I'm sure there's a way to do it, but the date modules haven't been
much help.

TIA
Ron

--
http://mail.python.org/mailman/listinfo/python-list

The datetime module has what you need.

It has methods (with examples) on building a datetime object from a string, and it has a object named timedelta, and the ability to subtract a timedelta from a time.

For instance, the time right now and the time exactly one day ago:

>>> from datetime import *
>>> datetime.today()
datetime.datetime(2008, 7, 10, 13, 38, 48, 279539)
>>> datetime.today()-timedelta(1)
datetime.datetime(2008, 7, 9, 13, 38, 50, 939580)


Gary Herron

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to