Einzelnen Beitrag anzeigen

Delphi.Narium

Registriert seit: 27. Nov 2017
2.508 Beiträge
 
Delphi 7 Professional
 
#3

AW: How to pass a computed date variable to a where sql command

  Alt 7. Jun 2020, 10:09
Delphi-Quellcode:
qry.DatabaseName := 'QDA8';
qry.Sql.Add('SELECT MyDB.TargetDate, MyDB.column02, MyDB.column04, MyDB.column06, MyDB.column08, MyDB.column09, MyDB.FIRMA');
qry.Sql.Add('FROM MyDB');
qry.Sql.Add('WHERE TargetDate = :dt');
qry.Sql.Add('Order by FIRMA');
qry.ParamByName('dt').AsDateTime := IncMonth(Now); // <--instead of function GetDate

…..strSQL := qry.Sql.GetText;
qry.Open;
strHeader := 'TargetDate;column02;column04;FIRMA;column09;column06;column08';
Writeln(tfFilePointer, strHeader);
tsSQLListe.Add(cTrenner + qry.FieldByName('TargetDate').AsString);
tsSQLListe.Add(cTrenner + qry.FieldByName('column02').AsString);
tsSQLListe.Add(cTrenner + qry.FieldByName('FIRMA').AsString);
tsSQLListe.Add(cTrenner + qry.FieldByName('column04').AsString);
tsSQLListe.Add(cTrenner + qry.FieldByName('column06').AsString);
tsSQLListe.Add(cTrenner + qry.FieldByName('column08').AsString);
tsSQLListe.Add(cTrenner + qry.FieldByName('column09').AsString);
  Mit Zitat antworten Zitat