Value exceeds the range for valid timestamps

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Fabrice
Posts: 45
Joined: Tue 07 Sep 2010 09:44

Value exceeds the range for valid timestamps

Post by Fabrice » Tue 09 Nov 2021 13:55

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 ?

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Value exceeds the range for valid timestamps

Post by ViktorV » Tue 16 Nov 2021 13:27

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.

Post Reply