date reformatting

Larry Bates larry.bates at websafe.com
Thu Oct 6 15:53:05 EDT 2005


There's more than one way, but this one will work for
dates prior to 2000.

import time
datestring='8-15-05'
d=time.strptime(datestring,'%m-%d-%y')
number=10000*d[0]+100*d[1]+d[2]
print number

-Larry Bates

Bell, Kevin wrote:
> Anyone aware of existing code to turn a date string "8-15-05" into the
> number 20050815?
> 
> The dateutil module has a parse method that looks perfect, I downloaded
> and unzipped it, but could figure out how to install it.  I using
> windows XP and py2.4.  
> 
> Any ideas?
> 
> 
> Kev
> 




More information about the Python-list mailing list