Can anyone suggest a date peocedure...
larry.bates at websafe.com`
Fri Jul 11 02:21:52 CEST 2008
> On Thu, 10 Jul 2008 13:39:29 -0700, Gary Herron
> <gherron at islandtraining.com> wrote:
>> 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.datetime(2008, 7, 10, 13, 38, 48, 279539)
>> datetime.datetime(2008, 7, 9, 13, 38, 50, 939580)
>> Gary Herron
> Thanks Gary! This works great. Now all I need to know is how to
> plug the date into the datetime object from a string.
I really shouldn't do this until you have put forth at least a little effort...
Type the following into the Python interpreter:
Help on built-in function strptime:
string, format -> new datetime parsed from a string (like time.strptime()).
Note: Looking in Python manual or Googling for time.strptime (to get proper
format for YYYYMMDD)
dstr = "20070710"
dt = datetime.datetime.strptime(dstr, "%Y%m%d")
datetime.datetime(2008, 7, 10, 0, 0)
More information about the Python-list