How to get the millisecond value from a Timestamp field in firebird with Delphi 2007

Posted by Re0sless on Stack Overflow See other posts from Stack Overflow or by Re0sless
Published on 2009-09-14T15:28:09Z Indexed on 2010/05/03 10:38 UTC
Read the original article Hit count: 809

Filed under:
|
|
|
|

I have a Firebird database (running on server version 2.1.3) and am connecting to it with Delphi 2007 using the DBExpress objects (using the Interbase driver)

One of my tables in the database looks something like this

CREATE TABLE MYTABLE
(
  MYDATE Timestamp NOT NULL,
  MYINDEX Integer NOT NULL,
  ...
  Snip
  ...
  PRIMARY KEY (MYDATE ,MYINDEX)
);

I can add to the table OK, and in Flame Robin it shows the timestamp field as having a millisecond value.

But when I do a select all (select * from MYTABLE) on the table I can not get the millisecond value, as it is always returned as 000.

This causes major problems as it is part of the primary key (unfortunately I didn't design the table and don't have authority to change it).

I have tried the following to get the millisecond value:

sql1.fieldbyname('MYDATE').AsDateTime;
sql1.fieldbyname('MYDATE').AsSQLTimeStamp;
sql1.fieldbyname('MYDATE').AsStirng;
sql1.fieldbyname('MYDATE').AsFloat;

But they all return 14/09/2009 14:25:06.000 when formatted.

How do I retrieve the millisecond from a timestamp?

UPDATE: In case this helps anyone in the future, here are the drivers I tried for DBExpress and the results.

© Stack Overflow or respective owner

Related posts about sql

Related posts about delphi