Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TField.AsDateTime precision issue

62 views
Skip to first unread message

Ömür Ölmez

unread,
Jul 4, 2008, 6:30:14 AM7/4/08
to
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

unread,
Jul 4, 2008, 10:04:54 AM7/4/08
to
> So, I guess, ib server has enough precision, but ibx truncates it some how.
> Is it true ?

Yes.

> 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

unread,
Jul 4, 2008, 9:22:02 AM7/4/08
to
> 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


"Dimitry Sibiryakov" <aaf...@mail.ru> wrote in message
news:486e...@newsgroups.borland.com...

Dimitry Sibiryakov

unread,
Jul 4, 2008, 4:07:22 PM7/4/08
to
> the data does not seems valid double raw bytes

Right. Because it is not TDateTime, but TISC_TIMESTAMP.

SY, SD.

0 new messages