ciao a tutti,
sapete per caso qual è la sintassi corretta per selezionare tutti i record che hanno il campo "Data" compreso in un certo intervallo. Per intenderci: ho due Edit (data1 e data2) nei quali scrivo le due date; cliccando su un tasto la query deve eseguire la selezione dei record che hanno la data compresa fra data1 e data2.
Purtroppo la query viene eseguita ma non mostra alcun record...
Ecco il codice:
codice:
procedure TForm1.Button1Click(Sender: TObject);
var
num_and: integer;
begin
with ADOQuery1 do begin
with SQL do begin
Clear;
Add('SELECT *');
Add('FROM tabella1');
Add('where');
num_and:=0;
if checkbox1.Checked then
begin
if num_and > 1 then
begin
SQL.Add ('AND ');
end;
SQL.Add('data>='+edit1.text);
num_and:=num_and+1;
end;
if checkbox2.Checked then
begin
num_and:=num_and+1;
if num_and>1 then
begin
SQL.Add ('AND ');
end;
SQL.Add('data<='+edit2.text);
end;
end;
Open;
num_and:=0;
end;
ciao!