[python-sybase] Milliseconds missing in Sybase.datetime

Bradley Feldman bradley at relevantevidence.com
Thu Sep 8 09:24:36 EST 2005


Dave:

I've been working with the Sybase module (latest version) and have run into
a snag in dealing with very precise datetime values.   In my case, I need to
preserve a Full datetime value **including milliseconds** and pass it on to
the database.

I'm using the following code:

sSubmit = str(datetime.datetime.now())
dtSubmit = Sybase.datetime(sSubmit)

This produces a DateTimeType object, but the msecond value is always zero.
It seems to get everything else correctly

It seemed like a silly parsing bug, so I tried a work around, grabbing the
milliseconds myself and trying to set them with:

dtSubmit.msecond = 349499 (whatever)

But this turned into a "TypeError: readonly attribute" exception

So now I'm stuck.  Have you or anyone else got a workaround .... Or a quick
fix?  Is there a non-string way of creating a DateTimeType?  Don't see
anything else in the docs.

Many thanks in advance!
*Bradley



More information about the Python-sybase mailing list