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).
Fábio R. Bot da Silva.