Subject Re: [firebird-support] SQL error
Author Stefan Heymann
> var
> ws_bdr_date : TDateTime
> [...]
> ws_bdr_date := StrToDate(Edit1.Text);
> [...]
> 'where adj.ADJ_DATE = ws_bdr_date ' +

You must quote your date with a single quote and you must use the
variable's content, not its name, so that gets:

'where adj.ADJ_DATE = ''' + FormatDateTime
('mm/dd/yyyy', ws_bdr_date) + '''' +

(same for all the other lines with dates in them).

I use this function to convert a TDateTime to a correctly quoted
string:

CONST
Months : ARRAY [1..12] OF STRING [3] =
('JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC');

FUNCTION SqlStr (Value : TDateTime; NullOnZero : BOOLEAN = FALSE) : STRING;
BEGIN
IF NullOnZero AND (Value = 0.0)
THEN Result := 'NULL'
ELSE Result := '''' + FormatDateTime ('DD', Value) + '-' + Months [MonthOfDate (Value)] +
'-' + FormatDateTime ('YYYY HH:NN:SS', Value) + '''';
END;

so your line would become

'where adj.ADJ_DATE = ' + SqlStr (ws_bdr_date) +

using the above function (I have similar SqlStr functions for Strings,
Integers, Booleans and Floats; using OVERLOAD they all are named
SqlStr).


Best Regards

Stefan