Re: date reformatting
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: date reformatting

From: Larry Bates <larry.bates@websafe.com>
Date: Thu Oct 06 2005 - 21:53:05 CEST

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
>
Received on Sat Oct 15 04:14:05 2005