Discussion:
TField.AsDateTime precision issue
(too old to reply)
Ömür Ölmez
2008-07-04 10:30:14 UTC
Permalink
Hello,

I have a timestamp column in a table.
/*create table table1(
ts timestamp
);*/
I insert records into table as below :
IBQuery.SQL.Text :=Format(
'insert into table1(ts) values(''%s'')',
[FornatDateTime('d.m.yyyy h:n:s:z', dtValue)]);

And I can see exact time value if I query by using console (Ex. 4.7.08
13:20:14.217).

But,
* In TDBGrid components, I always see tree zero as millisecond part of field
value even I set Field's DisplayFormat as 'dd.mm.yyyy hh:nn:ss:zzz'
properly.
* In programmatically accesing value as below, I always see tree zero again
:
var
dt :TDateTime;
begin
dt :=IBQuery1.FieldByName('ts').AsDateTime;
ShowMessage(FormatDateTime('dd.mm.yyyy hh:nn:ss:zzz', dt));
* If I try, FieldByName('ts').AsSQLTimestamp, it raises exception because of
it is not implemented (Delphi 6 EE).
* If I try getting data, by using GetFieldData method, the 8 bytes raw data
which comes from TField is differ from the 8 bytes raw data view of
TDateTime which I prepared by using EncodeDate and EncodeTime.

So, I guess, ib server has enough precision, but ibx truncates it some how.
Is it true ?

I do not need exact values in visuals (in TDBGrid etc.) I need excat values
when I access programmaticaly.
Is there any solution ?

Regards
Ömür Ölmez
Dimitry Sibiryakov
2008-07-04 14:04:54 UTC
Permalink
Post by Ömür Ölmez
So, I guess, ib server has enough precision, but ibx truncates it some how.
Is it true ?
Yes.
Post by Ömür Ölmez
I do not need exact values in visuals (in TDBGrid etc.) I need excat values
when I access programmaticaly.
Is there any solution ?
Access data directly as TISC_TIMESTAMP.

SY, SD.
Omur Olmez
2008-07-04 13:22:02 UTC
Permalink
Post by Dimitry Sibiryakov
Access data directly as TISC_TIMESTAMP.
Do you mean by using direct API call ?

I asked because I tried something like :

< TField > DataSize property says 8 and after
< TField > . GetData( pBuff, true);
the data does not seems valid double raw bytes

Thank you so much
Omur
Post by Dimitry Sibiryakov
Post by Ömür Ölmez
So, I guess, ib server has enough precision, but ibx truncates it some
how. Is it true ?
Yes.
Post by Ömür Ölmez
I do not need exact values in visuals (in TDBGrid etc.) I need excat
values when I access programmaticaly.
Is there any solution ?
Access data directly as TISC_TIMESTAMP.
SY, SD.
Dimitry Sibiryakov
2008-07-04 20:07:22 UTC
Permalink
Post by Omur Olmez
the data does not seems valid double raw bytes
Right. Because it is not TDateTime, but TISC_TIMESTAMP.

SY, SD.

Loading...