Page 1 of 1

Milliseconds are added to TimeStamp

Posted: Sat 18 Apr 2015 00:11
by Ruben
Hello,

Test done with Firebird 2.5 under DXE7

Devart DBXdriver 4.6.9 (same problem with previous versions)

The problem : DBXDriver add milliseconds to timeStamp value

To reproduce set now() to a timeStamp : myDataSet.FieldByName('MYTIMESTAMP').AsDateTime := now; and then applyUpdates. => The timeStamp has millisecond in the dataBase

Function now() doesn't returns millisecond

I don't see paramaters to avoid this, so I suppose that it's a bug

Embarcadero DBXDriver doesn't add milliseconds when I set now to a timeStamp and doesn't returns millisonds in dataSet (but I can't say if return milliseconds is a bug).

I my project I don't want to display milliseconds in the DBGrids and so it's impoosible to make a filter on timestamp fields.
That's why I don't want to have milliseconds in timeStamp fields.

Thanks

Re: Milliseconds are added to TimeStamp

Posted: Mon 20 Apr 2015 12:02
by ViktorV
Thank you for the information. We are investigating this behavior of dbExpress driver for InterBase and Firebird, and we will inform you about the results.
To store a value without milliseconds in the TSQLTimeStamp field, you can use the following code:

Code: Select all

var
  Time: TSQLTimeStamp;
begin
  Time := DateTimeToSQLTimeStamp(Now);
  Time.Fractions := 0;
  myDataSet.Append;
  myDataSet.FieldByName('MYTIMESTAMP').AsSQLTimeStamp := Time;
end;

Re: Milliseconds are added to TimeStamp

Posted: Tue 21 Apr 2015 09:04
by ViktorV
According to the official documentation, Firebird stores time in a TIMESTAMP field with millisecond accuracy:
http://www.firebirdsql.org/file/documen ... stamp.html
Respectively, our driver takes into account this server specificity and allows to store milliseconds in TIMESTAMP fields. Therefore, if you need no milliseconds in the grid or any other controls, it is better to configure this in the settings of the controls.

Re: Milliseconds are added to TimeStamp

Posted: Wed 22 Apr 2015 11:22
by Ruben
Thank you very much for your support

I will use your piece of code to not have milliseconds.

Embarcadero DBXDriver is bugged in this case ...
and also the documentation, because now() shouldn't return milliseconds

Thanks

Re: Milliseconds are added to TimeStamp

Posted: Wed 22 Apr 2015 11:56
by ViktorV
Feel free to contact us if you have any further questions about dbExpress driver for InterBase and Firebird.