Value from a "DATE data-type" field
Posted: Thu 17 Mar 2011 17:25
Hi there,
I'm having wrong results when getting value from DATE fields on Firebird.
Always the year comes incorrect. Please, see the code below:
The result is "16/03/3910", the correct is "16/03/2011".
The RDB$DATABASE was used for sample, but this happens with any date field.
Does anyone knows about this ?
To try the sample don't forget to add DBXCommon to your uses clause.
Firebird 2.1.4 - Delphi 2010 - DBXIda 2.70.28
(By the way, the new resource "lock timeout for wait transactions" is working perfectly).
Thanks,
Fábio R. Bot da Silva.
I'm having wrong results when getting value from DATE fields on Firebird.
Always the year comes incorrect. Please, see the code below:
Code: Select all
procedure TFrmPrincipal.Button1Click(Sender: TObject);
var
DBXTrn: TDBXTransaction;
DBXCmd: TDBXCommand;
DBXRdr: TDBXReader;
dDta: TDateTime;
begin
dDta := 0;
if DM.DBXCon.Connected then
begin
DBXTrn := DM.DBXCon.DBXConnection.BeginTransaction(TDBXIsolations.ReadCommitted);
try
DBXCmd := DM.DBXCon.DBXConnection.CreateCommand;
try
DBXCmd.Text := 'SELECT CAST(''NOW'' AS DATE) AS MYDATE' +
' FROM RDB$DATABASE';
DBXCmd.Prepare;
DBXRdr := DBXCmd.ExecuteQuery;
if DBXRdr.Next then
dDta := DBXRdr.Value['MYDATE'].GetDate;
DBXCmd.Close;
DBXRdr.Free;
finally
DBXCmd.Free;
end;
DM.DBXCon.DBXConnection.CommitFreeAndNil(DBXTrn);
except
DM.DBXCon.DBXConnection.RollBackFreeAndNil(DBXTrn);
raise;
end;
end;
ShowMessage(FormatDateTime('dd/mm/yyyy', dDta));
end;
The RDB$DATABASE was used for sample, but this happens with any date field.
Does anyone knows about this ?
To try the sample don't forget to add DBXCommon to your uses clause.
Firebird 2.1.4 - Delphi 2010 - DBXIda 2.70.28
(By the way, the new resource "lock timeout for wait transactions" is working perfectly).
Thanks,
Fábio R. Bot da Silva.