Python 2.3 ODBC Datetime limitations
YuePing Lu
yueping.lu at gmail.com
Fri Jun 1 14:12:49 EDT 2007
Hello,
Has any of you ever used Python odbc to retrieve data from a relational DB?
I encountered a problem where it can't handle datetime *earlier than **1969*,
and *later than **2040*. It just returned some garbage strings when I call
str(my_date_object).
When I call strptime to convert the value I got ValueError exception:
# Table records
for record in self._records:
columns = []
for i in range(len(self._description)):
if self._description[i][1]=='DATE':
strDate=str(record[i])
try:
#convert the date format to be mm/dd/yyyy:
oDate=time.strptime(strDate) #convert to struct_time object
strfDate=time.strftime("%m/%d/%Y", oDate)
columns.append(strfDate)
except ValueError, msg:
raise "Date converstion error", msg
...
Any other solutions that you've heard?
Thanks very much in advance,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070601/cafce002/attachment.html>
More information about the Python-list
mailing list