ADOdbapi converting all data to strings

Robert Brewer fumanchu at amor.org
Mon Aug 16 08:17:56 CEST 2004


max wrote:
> I am trying to access a foxpro database, using odbc all is well except
> that dates prior to 1970 are not returned as valid usable data, so
> would like to use ADO. When I select data containing numbers (long or
> float) they are converted and returned as unicode strings. Dates are
> returned as datetime.date which is great. Is there any way to change
> this behavior other than to explicitly change back all fields using
> cursor.description information.

I *think* you're saying that you have a COM date (which is similar to a
float), and want a datetime.date.


import datetime
# 12/30/1899, the zero-Date for ADO = 693594
zeroDate = datetime.date(1899, 12, 30).toordinal()

def coerce_datetime(value):
    return datetime.date.fromordinal(int(float(value)) + zeroDate)


COM times are more complicated. Inquire further if you need to handle
them.


Robert Brewer
MIS
Amor Ministries
fumamchu at amor.org



More information about the Python-list mailing list