datetime milliseconds with ado ms-sqlserver

The forum for ZeosLib 7.2 Report problems. Ask for help, post proposals for the new version and Zeoslib 7.2 features here. This is a forum that will be edited once the 7.2.x version goes into RC/stable!!

My personal intention for 7.2 is to speed up the internals as optimal a possible for all IDE's. Hope you can help?! Have fun with testing 7.2
Post Reply
woec
Fresh Boarder
Fresh Boarder
Posts: 13
Joined: 23.04.2013, 20:47

datetime milliseconds with ado ms-sqlserver

Post by woec »

Hi,

in my database application I insert log data into ms sql-server database using ado protocol (ZeosLib 7.2.4 stable, Lazarus 1.8.4 Win 32 and Win64).
Log data contains a datetime timestamp. I encountered the problem, that the millisecond part of the timestamp data is lost at the insert. Only the datetime part down to seconds ist inserted.

Reading the documentation, I found a connection parameter DateTimeWriteFormat to be specified as TZConnection.property. But I could not find any information how to supply the format - it should be according to Delphi standard, but where find this specificaton?

I am also not sure if this parameter, if set correctly, will help to solve my problem.

Can anybody help here?

woec
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: datetime milliseconds with ado ms-sqlserver

Post by marsupilami »

Hello,

you can set DateTimeWriteFormat like this:

Code: Select all

ZConnection.Properties.Add('DateTimeWriteFormat=YYYY-MM-DD HH:NN:SS.ZZZ')
The format specification is the same specification that FormatDateTime uses.

I am not sure if that helps with ADO and MSSQL though because the SQL Server ADO driver should be able to use parameters.

Best regards,

Jan
woec
Fresh Boarder
Fresh Boarder
Posts: 13
Joined: 23.04.2013, 20:47

Re: datetime milliseconds with ado ms-sqlserver

Post by woec »

Thank you for the hint.

I tried it, but it does not solve the problem - no change in behavior.

The datetime value is already defined as ftDateTime Parameter type in the TZQuery properties.
Also, I tried different settings for size and precision for this parameter, but also no change.

woec
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: datetime milliseconds with ado ms-sqlserver

Post by marsupilami »

Hello,

which column type do you use in the database?
Best regards,

Jan
woec
Fresh Boarder
Fresh Boarder
Posts: 13
Joined: 23.04.2013, 20:47

Re: datetime milliseconds with ado ms-sqlserver

Post by woec »

Hi,

I use the "datetime" datatype for this timestamp in the ms sql-server database.

woec
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Re: datetime milliseconds with ado ms-sqlserver

Post by EgonHugeist »

please test datetime2
because SQLServer does some roundings using the datetime type
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
Post Reply