I have the function as follows:
function FDOM(Date: TDateTime): TDateTime;
var
Year, Month, Day: Word;
begin
DecodeDate(Date, Year, Month, Day);
Result := EncodeDate(Year, Month, 1);
end;
I use
ShowMessage(DateToStr(FDOM(Now)));
firstdayofmonth := DateToStr(FDOM(Now));
then
temp := 'SELECT SUM(Inv_Nett) FROM Invoice WHERE INV_DATE > (firstdayofmonth)';
Datamodule7.MyQuery_Inv_Sum.SQL.Text := temp;
Datamodule7.MyQuery_Inv_Sum.Open;
I fall over on the fistdayofmonth
What is the correct syntax.
I need to get the sum of all the invoices created in the current month.
Any help appreciated.
SteveW
Delphi Query. > than 1st day of month
You should use something like this:
Code: Select all
var
firstdayofmonth: TDateTime;
firstdayofmonth := FDOM(Now);
temp := 'SELECT SUM(Inv_Nett) FROM Invoice WHERE INV_DATE > :firstdayofmonth';
Datamodule7.MyQuery_Inv_Sum.SQL.Text := temp;
Datamodule7.MyQuery_Inv_Sum.Params[0].AsDateTime := firstdayofmonth;
Datamodule7.MyQuery_Inv_Sum.Open;