在1列中过滤2个日期 [英] Filter between 2 dates in 1 column

查看:80
本文介绍了在1列中过滤2个日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码,我不知道问题出在哪里,所以请帮我修理一下谢谢



我尝试过:



程序TForm1.Button1Click(发件人:TObject);

开始

ADODataSet1.Close ;

ADODataSet1.CommandText:='[Date]> ='+ quotedStr(DateToStr(Date1.date))+'和'+'[Date]< ='+ QuotedStr(DateToStr( Date2.Date));

ADODataSet1.Active:= True;

ADODataSet1.Requery();

end;



程序TForm1.Button2Click(发件人:TObject);

开始

ADODataSet1.Close;

结束;

end。

Hi this is my code and I don't know where is the problem so help me please to fix it thanks

What I have tried:

procedure TForm1.Button1Click(Sender: TObject);
begin
ADODataSet1.Close;
ADODataSet1.CommandText :='[Date]>='+quotedStr(DateToStr(Date1.date))+'and'+'[Date]<='+QuotedStr(DateToStr(Date2.Date));
ADODataSet1.Active := True;
ADODataSet1.Requery();
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
ADODataSet1.Close;
end;
end.

推荐答案

你的CommandText属性应该是一个完整的SQL语句,而不仅仅是一个过滤器。



使用完整SQL语句中的参数,或使用现有代码作为过滤器。
Your CommandText property should be a complete SQL statement, not just a filter.

Either use parameters in the full SQL statement, or use your existing code as a filter.


这篇关于在1列中过滤2个日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆