ADOQuery1 inside report
Hi is it possible to filter by date by parameter like this inside the report and make a trend?
Thank??s
procedure ChangeParamDate(Param: TParameter; const Value: TDateTime);
begin
Param.Value := Value;
Param.DataType := ftDate;
end;
begin
with qerymatdata do
begin
Close;
SQL.Text :=
'SELECT '+
'a.Codigo, '+
'a.Designacao, '+
'Sum(a.Quantidade) AS SomaDeQuantidade, '+
'FORMAT(a.data_hora, ''dd.yyyy'') AS [MonthAndYear] '+
'FROM Materiais_obraRel AS a '+
'WHERE (a.data_hora BETWEEN @DataInicDate AND @DataFinalDate) '+
'GROUP BY '+
'Year(a.data_hora), '+
'Month(a.data_hora), '+
'a.Codigo, '+
'a.Designacao, '+
'FORMAT(a.data_hora, ''dd.yyyy'') '+
'ORDER BY '+
'a.Codigo, '+
'a.Designacao ';
ChangeParamDate(Parameters.ParamByName('@DataInicDate'), datainic.DateTime);
ChangeParamDate(Parameters.ParamByName('@DataFinalDate'), datafinal.DateTime);
Open;
end;
end;
Thank??s
procedure ChangeParamDate(Param: TParameter; const Value: TDateTime);
begin
Param.Value := Value;
Param.DataType := ftDate;
end;
begin
with qerymatdata do
begin
Close;
SQL.Text :=
'SELECT '+
'a.Codigo, '+
'a.Designacao, '+
'Sum(a.Quantidade) AS SomaDeQuantidade, '+
'FORMAT(a.data_hora, ''dd.yyyy'') AS [MonthAndYear] '+
'FROM Materiais_obraRel AS a '+
'WHERE (a.data_hora BETWEEN @DataInicDate AND @DataFinalDate) '+
'GROUP BY '+
'Year(a.data_hora), '+
'Month(a.data_hora), '+
'a.Codigo, '+
'a.Designacao, '+
'FORMAT(a.data_hora, ''dd.yyyy'') '+
'ORDER BY '+
'a.Codigo, '+
'a.Designacao ';
ChangeParamDate(Parameters.ParamByName('@DataInicDate'), datainic.DateTime);
ChangeParamDate(Parameters.ParamByName('@DataFinalDate'), datafinal.DateTime);
Open;
end;
end;