Incompatibility between Date field (Oracle) and TDateTime
Posted: 03.08.2007, 16:15
When a table column is defined as:DATE (See Additional Information).
And we try to execute the following code:
var
dt1 : TDateTime;
str : STring;
begin
dt1 := ZTable1.FieldByName('FH').AsDateTime;
str := DateTimeToStr(dt1);
...
The result (str or dt1) have not the time part, its say, we only resolve the date part of the field data base (DATE type).
ie. If the information store in the DB is "7/3/2007 10:11:22 AM", the code only return
"7/3/2007"
and lose
"10:11:22 AM"
The following code make the same:
str := ZTable1.FieldByName('FH').AsString;
We make a test with the same code, but using ADO technology and every thing work OK.
We make a test with the same code, but using MySQL and using a Data Base Field DateTime type and every thing work OK too.
The problem is present in the 6.6.0 Beta Version too.
Oracle Table's DDL:
CREATE TABLE ESCHEMA1.TABLE1
(
FH DATE,
N NUMBER(12,9)
)
NOPARALLEL
PCTFREE 10
INITRANS 1
STORAGE (
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
)
TABLESPACE TECHDB
NOLOGGING
NOCACHE
NOMONITORING
NOROWDEPENDENCIES;
And we try to execute the following code:
var
dt1 : TDateTime;
str : STring;
begin
dt1 := ZTable1.FieldByName('FH').AsDateTime;
str := DateTimeToStr(dt1);
...
The result (str or dt1) have not the time part, its say, we only resolve the date part of the field data base (DATE type).
ie. If the information store in the DB is "7/3/2007 10:11:22 AM", the code only return
"7/3/2007"
and lose
"10:11:22 AM"
The following code make the same:
str := ZTable1.FieldByName('FH').AsString;
We make a test with the same code, but using ADO technology and every thing work OK.
We make a test with the same code, but using MySQL and using a Data Base Field DateTime type and every thing work OK too.
The problem is present in the 6.6.0 Beta Version too.
Oracle Table's DDL:
CREATE TABLE ESCHEMA1.TABLE1
(
FH DATE,
N NUMBER(12,9)
)
NOPARALLEL
PCTFREE 10
INITRANS 1
STORAGE (
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
)
TABLESPACE TECHDB
NOLOGGING
NOCACHE
NOMONITORING
NOROWDEPENDENCIES;