Difference between revisions of "Python - DbiDate"

From PeformIQ Upgrade
Jump to navigation Jump to search
(New page: =References= * =Notes= Accessing a SqlServer dataabse via the ActiveState Python ODBC implementation returns dates as a DbiDate object. To convert them into a datetime formate where t...)
 
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
=References=
=References=


*  
* [http://www.python.org/doc/2.5/lib/module-datetime.html Python datetime module reference]


=Notes=
=Notes=
==Conversion==


Accessing a SqlServer dataabse via the ActiveState Python ODBC implementation returns dates as a DbiDate object.
Accessing a SqlServer dataabse via the ActiveState Python ODBC implementation returns dates as a DbiDate object.
Line 12: Line 14:
dt = datetime.datetime.fromtimestamp(int(dbidate))
dt = datetime.datetime.fromtimestamp(int(dbidate))
</pre>
</pre>
==DbiDate Use in SELECT==
For selects, use the datetime object directly -
<pre>
cur.execute('select * from table where date = ?',(dt,))
</pre>


[[Category:Python]]
[[Category:Python]]
[[Category:ODBC]]
[[Category:ODBC]]

Latest revision as of 12:39, 28 May 2008

References

Notes

Conversion

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,))