Alternative to strptime()?
Mio Nino Marquez
mionino at d1.com.sg
Mon Sep 11 19:57:37 EDT 2000
First, thanks for the help.
However, we still couldn't figure out how to do it. <g>
Here's our code snippet:
import rfc822, time
sDate = '2000-12-20 00:00:00' #date the MSSQL db is giving
dTime = rfc822.parsedate(sDate) #request for a 9-tuple
dtuple = time.strftime('%Y%m%d', dTime) #we'd like to have the date
formatted as yyyymmdd
return dtuple
It is my understanding that if I set sDate to 'Tue, 12 Sep 2000
00:00:00 -0500', then the above snippet works.
We've tried converting '2000-12-20 00:00:00' to 'Tue, 12 Sep 2000
00:00:00 -0500' but couldn't find any way how to do it.
Please help.
Mio Nino Marquez
"Skip Montanaro" <skip at mojam.com> wrote in message
news:14781.1818.450384.154304 at beluga.mojam.com...
> >>>>> "Dan" == Dan Schmidt <dfan at thecia.net> writes:
>
> Mio> ... we'd like to convert a date-formatted string into a Tuple
> Mio> ... but strptime() appears to be not working in Win32.
>
> Dan> I bet rfc822.parsedate_tz() will do the job for you.
>
> You might also want to check out Marc-Andre Lemburg's mxDateTime package.
> It can parse a lot of date/time formats. You can find it at
>
> http://starship.python.net/crew/lemburg
>
> --
> Skip Montanaro (skip at mojam.com)
> http://www.mojam.com/
> http://www.musi-cal.com/
>
More information about the Python-list
mailing list