Page 1 of 1

Value exceeds the range for valid timestamps

Posted: Tue 09 Nov 2021 13:55
by Fabrice
Hello,

Test on Firebird 3.0.7 and different version of IBDAC (included last one).

When using AsDatetime a value can cause a SQL Error "Value exceeds the range for valid timestamps"

This code :

Code: Select all

procedure TForm17.Button1Click(Sender: TObject);
var
  i:integer;
  MaDateIntervention,dummy:Tdatetime;
  myYear,myMonth, myDay,MyHour,MyMinute,MySecond,MyMilliseconde:word;
  ValeurPrecise:double;
begin
     MaDateIntervention :=  now;
     DecodeDate(MaDateIntervention, myYear, myMonth, myDay);
     MaDateIntervention := EncodeDateTime(myYear, myMonth, myDay, 9, 00, 00, 00);



     for i:=0 to 20 do
     begin
       
        MaDateIntervention  := MaDateIntervention + 1/24;

       IBCQuery1.ParamByName('MyDate').DataType:=  ftDateTime;
       IBCQuery1.ParamByName('MyDate').asdatetime:= MaDateIntervention;

       IBCQuery1.ExecSQL;

     end;



end;
With :

Code: Select all

object IBCQuery1: TIBCQuery
  Connection = IBCConnection1
  SQL.Strings = (
    'insert into DB_KEY_TABLE'
    '(STAMP_ADD)'
    'values'
    '(:MyDAte)')
  Left = 272
  Top = 72
  ParamData = <
    item
      DataType = ftUnknown
      Name = 'MyDAte'
      Value = nil
    end>
end

Of course the solution is to replace ;

Code: Select all

 MaDateIntervention  := MaDateIntervention + 1/24;
by :

Code: Select all

 MaDateIntervention:=incHour(MaDateIntervention,1);
Because of value = 44510,99999999996360. Of cource fixed by using IncHour. But Delphi handle these date without any problem.

So there is no check/filter in IBDAC level. Does it exists a way, with an explicit DataType and AsDateTime, to force check or convert or round a TimeStamp value at IBDAC level ?

Re: Value exceeds the range for valid timestamps

Posted: Tue 16 Nov 2021 13:27
by ViktorV
Thank you for letting us know about this unfortunate situation. We would like to inform you that we have successfully reproduced this issue and at the moment our team is investigating it. I would like to kindly assure you that as soon as we have any results, we will immediately let you know.