Milliseconds are added to TimeStamp

Milliseconds are added to TimeStamp

Postby Ruben » Sat 18 Apr 2015 00:11

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
Ruben
 
Posts: 2
Joined: Fri 17 Apr 2015 23:34

Re: Milliseconds are added to TimeStamp

Postby ViktorV » Mon 20 Apr 2015 12:02

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;
ViktorV
Devart Team
 
Posts: 1833
Joined: Wed 30 Jul 2014 07:16

Re: Milliseconds are added to TimeStamp

Postby ViktorV » Tue 21 Apr 2015 09:04

According to the official documentation, Firebird stores time in a TIMESTAMP field with millisecond accuracy:
http://www.firebirdsql.org/file/documentation/reference_manuals/reference_material/html/langrefupd20-current_timestamp.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.
ViktorV
Devart Team
 
Posts: 1833
Joined: Wed 30 Jul 2014 07:16

Re: Milliseconds are added to TimeStamp

Postby Ruben » Wed 22 Apr 2015 11:22

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
Ruben
 
Posts: 2
Joined: Fri 17 Apr 2015 23:34

Re: Milliseconds are added to TimeStamp

Postby ViktorV » Wed 22 Apr 2015 11:56

Feel free to contact us if you have any further questions about dbExpress driver for InterBase and Firebird.
ViktorV
Devart Team
 
Posts: 1833
Joined: Wed 30 Jul 2014 07:16


Return to dbExpress driver for InterBase & Firebird