楼上的大虾一不小心:
Sql.Add('Select * from TableName Where Date>=StartDate and Date<=EndDate');
应为:
Sql.Add('Select * from TableName Where Date>='+StartDate+' and Date<='+EndDate);
吧
var yy,mm,dd :Word;
StartDate,EndDate: TDateTime;
begin
DecodeDate(now,yy,mm,dd);
dd:=MonthDays[IsLeapYear(yy),mm];// 当前年月的天数;
StartDate:=EncodeDate(yy,mm,1); // 当前年月的第一天;
EndDate:=EncodeDate(yy,mm,dd); // 当前年月的最后一天;
Sql.Add('Select * from TableName Where Date>=StartDate and Date<=EndDate');
end;