select * from a.db where month(登记日期)<month(getdate()) and year(登记日期)<year(getdate())
select * FROM a.db WHERE 登记日期>=:d1 and 登记日期<:d2程序中: ParamByName('D1').AsDate := “当月一号” ParamByName('D2').AsDate := “下月一号”注:在 paradox 数据库,中没有提供太多的内建函数,这是你只有借助程序将其设计出来。
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;
楼上的大虾一不小心: Sql.Add('Select * from TableName Where Date>=StartDate and Date<=EndDate'); 应为: Sql.Add('Select * from TableName Where Date>='+StartDate+' and Date<='+EndDate); 吧
在Paradox表设计中将month定为第二索引,好象可以解决Invalid use of keyword Token:month 的问题。
Invalid use of keyword
Token:month
and year(登记日期)<year(getdate())
ParamByName('D1').AsDate := “当月一号”
ParamByName('D2').AsDate := “下月一号”注:在 paradox 数据库,中没有提供太多的内建函数,这是你只有借助程序将其设计出来。
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;
Sql.Add('Select * from TableName Where Date>=StartDate and Date<=EndDate');
应为:
Sql.Add('Select * from TableName Where Date>='+StartDate+' and Date<='+EndDate);
吧
Token:month 的问题。