Python - DbiDate

From PeformIQ Upgrade
Jump to navigation Jump to search




Accessing a SqlServer dataabse via the ActiveState Python ODBC implementation returns dates as a DbiDate object.

To convert them into a datetime formate where they are more easily manipulated do the following:

dt = datetime.datetime.fromtimestamp(int(dbidate))

DbiDate Use in SELECT

For selects, use the datetime object directly -

cur.execute('select * from table where date = ?',(dt,))