<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent changes to 43: Invalid microsecond conversion using DateTimeAsPython</title><link href="https://sourceforge.net/p/python-sybase/bugs/43/" rel="alternate"/><link href="https://sourceforge.net/p/python-sybase/bugs/43/feed.atom" rel="self"/><id>https://sourceforge.net/p/python-sybase/bugs/43/</id><updated>2013-10-08T16:06:59.095000Z</updated><subtitle>Recent changes to 43: Invalid microsecond conversion using DateTimeAsPython</subtitle><entry><title>Invalid microsecond conversion using DateTimeAsPython</title><link href="https://sourceforge.net/p/python-sybase/bugs/43/" rel="alternate"/><published>2013-10-08T16:06:59.095000Z</published><updated>2013-10-08T16:06:59.095000Z</updated><author><name/><uri>https://sourceforge.net</uri></author><id>https://sourceforge.netf61badab7adf4a3a45ae4ce3644da523079aa584</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;When using &lt;code&gt;DateTimeAsPython&lt;/code&gt; for my output map, I found that the microsecond value in &lt;code&gt;datetime.datetime&lt;/code&gt; was 1000 times the value stored in the database. here's a patch:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="gd"&gt;--- Sybase.py   (revision xxx)&lt;/span&gt;
&lt;span class="gi"&gt;+++ Sybase.py   (working copy)&lt;/span&gt;
&lt;span class="gu"&gt;@@ -197,10 +197,10 @@&lt;/span&gt;
     DateTimeAsPython = {
         CS_DATETIME_TYPE: lambda val: datetime.datetime(val.year, val.month + 1, val.day,
                                                         val.hour, val.minute,
&lt;span class="gd"&gt;-                                                        val.second, val.msecond * 1000),&lt;/span&gt;
&lt;span class="gi"&gt;+                                                        val.second, val.msecond),&lt;/span&gt;
         CS_DATETIME4_TYPE: lambda val: datetime.datetime(val.year, val.month + 1, val.day,
                                                          val.hour, val.minute,
&lt;span class="gd"&gt;-                                                         val.second, val.msecond * 1000) }&lt;/span&gt;
&lt;span class="gi"&gt;+                                                         val.second, val.msecond) }&lt;/span&gt;
     if _have_cs_date_type:
         DateTimeAsPython.update({
             CS_DATE_TYPE: lambda val: datetime.date(val.year, val.month + 1, val.day) })
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Additional note: &lt;code&gt;DateTimeAsPython&lt;/code&gt; also raises an error if the datetime field is NULL, probably not the desired behavior.&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>