Hello,
I have a strange problem.
In Delphi I execute the following source :
const
CST_DUREEINTERV = 1/24;
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
caption:=i.tostring;
MaDateIntervention := MaDateIntervention + CST_DUREEINTERV;
IBCQuery1.ParamByName('MyDate').DataType:= ftDateTime;
IBCQuery1.ParamByName('MyDate').asdatetime:= MaDateIntervention;
IBCQuery1.ExecSQL;
end;
end;
When i=14 Firebird will return an SQL Error :
"value exceeds the range for valid timestamps"
Ok the problem is that the date (MaDateIntervention ) value is correct for Delphi but not for Firebird so the solution is to do to use IncHour like this :
const
CST_DUREEINTERV = 1/24;
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
caption:=i.tostring;
MaDateIntervention:=incHour(MaDateIntervention,1);
// MaDateIntervention := MaDateIntervention + CST_DUREEINTERV;
IBCQuery1.ParamByName('MyDate').DataType:= ftDateTime;
IBCQuery1.ParamByName('MyDate').asdatetime:= MaDateIntervention;
IBCQuery1.ExecSQL;
end;
end;
But in scripter use IncHour doesn't solve the problem.
Of course do this :
DecodeDateTime(MaDateIntervention, myYear, myMonth, myDay,MyHour,MyMinute,MySecond,MyMilliseconde);
MaDateIntervention := EncodeDateTime(myYear, myMonth, myDay, MyHour, MyMinute, MySecond,MyMilliseconde);
But why I need to do it ?