How to convert a time object from MS Access database to string

Skip Montanaro skip at pobox.com
Fri Sep 7 00:25:39 EDT 2001


    Ng> How I can convert a time object read from the MS Access Database to
    Ng> a string.

    Ng> I checked the PyTime Object and used the example as follows:

    Ng>   rdate = time.localtime(int(rec[3]))

    Ng> but got the following error:

    Ng>   TypeError: object can't be converted to int

Well, obviously rec[3] doesn't look like an integer.  What does it look like
if you just print it out?  If it looks like a complex date/time sort of
thing like 

    Thu April 1 2001 10:38

you can probably parse it with time.strptime or use the functions available
in Marc-Andre Lemburg's mx.DateTime module to parse it.

-- 
Skip Montanaro (skip at pobox.com)
http://www.mojam.com/
http://www.musi-cal.com/




More information about the Python-list mailing list