Turns out it's the ODBC driver. Demo:
In [78]: cnxn = pyodbc.connect("DSN=local;")
In [79]: crsr = cnxn.execute("select cast('2012-01-01' as date) as bar")
In [80]: r = crsr.fetchone()
In [81]: type(r.bar)
Out[81]: unicode
Then, when switching to SQLNCLI10:
In [96]: cnxn = pyodbc.connect("Driver={SQL Server Native Client 10.0};Server=localhost;Trusted_Connection=Yes;")
In [97]: crsr = cnxn.execute("select cast('2012-01-01' as date) as bar")
In [98]: r = crsr.fetchone()
In [99]: type(r.bar)
Out[99]: datetime.date
2 comments:
Fantastic, worked like a charm and very timely.
Your post just saved me from quite a bit of unnecessary parsing for my date arithmetic in python.
Post a Comment