[egenix-users] mx.DateTime: Truncating fractional seconds

Wade Leftwich wade at lightlink.com
Sat Aug 9 09:24:03 CEST 2003


Steve Holden wrote:
> I've found that a number of platforms (Access, MS SQL Server) don't
> appear to like the fractional seconds part of a DateTime. The resulting
> warning messages are a little tedious (though I realise I *could*
> suppress them with the warnings module).
> 
> It's possible (though rather tedious) to reconstruct the object from its
> component attributes and truncate the seconds while so doing. I just
> wondered if anyone could think of a simpler way. I have this nagging
> feeling I'm overlooking the stunningly obvious.


On Win2K and SqlServer2000, I use int(myDateTimeObject) without problems:

cursor.execute("insert into myTable (myDateTimeColumn) values (?)", 
(int(myDateTimeObject),))

Not *stunningly* obvious, but ...

-- Wade Leftwich
Ithaca, NY





More information about the egenix-users mailing list