odbc DbiDate date conversion

Frank Millman frank at chagford.com
Wed Sep 27 04:43:44 EDT 2006


flupke wrote:
> Frank Millman schreef:
> <snip>
>
> > Well waddyaknow - I get exactly the same, for dates earlier than
> > 1970-01-02. Thanks for finding a bug that would have bitten me sooner
> > or later.
> >
> > I will do some investigation. If I find an answer I will post it here,
> > unless some kind soul saves me the trouble and beats me to it.
> >
> > Frank
> >
>
> Thanks for investigating it so far Frank.
>
> Is there a workaround to parse that date and get the date info that i want?
>

Not that I know of. The results of my investigations so far seem to
indicate that we have a problem :-(

Here is a link to an article dated 1998 -
    https://svn.python.org/www/trunk/pydotorg/windows/OdbcHints.html

Among other interesting stuff, it states -

"Notice that result values are converted to Python objects. Dates in
particular are returned as dbiDate objects. This can be a serious
limitation, because dbiDate can not represent dates prior to the UNIX
epoch (1 Jan 1970 00:00:00 GMT). If you try to retrieve earlier dates,
you'll get garbage and may even provoke a crash."

I contacted Mark Hammond, author of the win32 extensions, to ask if
there was a solution and particularly to suggest a modification to
return a datetime.datetime object. This was his reply -

"I'd be happy with an option to use the datetime module - maybe it
could even be on the cursor?  However, I wont have time to do this in
the short term.
You could consider using ADO via win32com too..."

It looks as if we will have to use ADO for now. There is an 'adodbapi'
module available which is DB-API 2.0 compliant -
adodbapi.sourceforge.net. I will give it a try.

Frank




More information about the Python-list mailing list