The Delphi Bug List

Entry No.
672
VCL - General - SqlTimSt
TryStrToSQLTimeStamp does not have the behaviour like it is described in the Help.
1.02 2.01 3.0 3.01 3.02 4.0 4.01 4.02 4.03 5.0 5.01 6.0 6.01 6.02 Kylix 1.0
N/AN/AN/AN/AN/AN/AN/AN/AN/AN/AN/AExistsFixedFixedExists
Description
Reported by Martijn Houtman; checked by Jordan Russell
There is a bug in Delphi 6.0, Build 6.136, SqlTimSt.pas. The function
function TryStrToSQLTimeStamp(const S: string; var TimeStamp: TSQLTimeStamp): Boolean;
var
  DT: TDateTime;
begin
  DT := StrToDateTime(S);
  TimeStamp := DateTimeToSQLTimeStamp(DT);
  Result := IsSqlTimeStampValid(TimeStamp);
end;
does not have the behaviour like it is described in the Help of Delphi 6.

Problem:
When the string S can not be converted to TSQLTimeStamp the result should be 'false' and TimeStamp = NullSqlTimeStamp. Instead of this an exception will be generated.

The function should be replaced with:

function TryStrToSQLTimeStamp(const S: string; var TimeStamp: TSQLTimeStamp): Boolean;
var
  DT: TDateTime;
begin
  Result := TryStrToDateTime(S, DT);
  if Result then
  begin
    TimeStamp := DateTimeToSQLTimeStamp(DT);
    Result := IsSqlTimeStampValid(TimeStamp);
  end;
  if not Result then
    TimeStamp := NullSqlTimeStamp;
end;
This bug causes also an exception when passing a string in TClientDataSet.SetOptionalParameter, like for example:
TClientDataSet.SetOptionalParameter('TABLE_NAME', 'mytablename')
Latest update of this entry: 2001-10-31

Post a comment on this bug


Index page
Delphi Bug List home page
The Delphi Bug Lists are presently maintained by Jordan Russell, who has taken over this task from Reinier Sterkenburg since August 2000.
All feedback is appreciated. See also the feedback section of the Delphi Bug List home page.