如何从表table 中查询出这样的记录???name shi_date end_date
客户 2006-5-1 2006-6-1
客户 2006-6-1 2006-7-1
记者 2006-8-1 2006-8-3Edit1,Edit2中的文本都为日期如何用ADOQuery1的sql语句选出Edit1.Text在shi_date与end_date之间或Edit2.Text在shi_date与end_date之间,SQL语句应如何写???这样写查询不出记录
--------------------------------------------------------------------------
ADOQuery1.Close;
ADOQuery1.SQL.Add('select * from table where '''+FormatDateTime('yyyy-m-d',StrToDate
(Edit1.Text))+''' >= shi_date and '''+FormatDateTime('yyyy-m-d',StrToDate
(Edit1.Text))+''' <=end_date or '''+FormatDateTime('yyyy-m-d',StrToDate(Edit2.Text))
+''' >= shi_date and '''+FormatDateTime('yyyy-m-d',StrToDate(Edit2.Text))+'''
<=end_date ');
ADOQuery1.Parameters.ParamByName('c_id').Value:=Edit3.Text;
ADOQuery1.Parameters.ParamByName('p_id').Value:=Edit4.Text;
ADOQuery1.Open;
--------------------------------------------------------------------------
这样写对不对,应该怎样写???
客户 2006-5-1 2006-6-1
客户 2006-6-1 2006-7-1
记者 2006-8-1 2006-8-3Edit1,Edit2中的文本都为日期如何用ADOQuery1的sql语句选出Edit1.Text在shi_date与end_date之间或Edit2.Text在shi_date与end_date之间,SQL语句应如何写???这样写查询不出记录
--------------------------------------------------------------------------
ADOQuery1.Close;
ADOQuery1.SQL.Add('select * from table where '''+FormatDateTime('yyyy-m-d',StrToDate
(Edit1.Text))+''' >= shi_date and '''+FormatDateTime('yyyy-m-d',StrToDate
(Edit1.Text))+''' <=end_date or '''+FormatDateTime('yyyy-m-d',StrToDate(Edit2.Text))
+''' >= shi_date and '''+FormatDateTime('yyyy-m-d',StrToDate(Edit2.Text))+'''
<=end_date ');
ADOQuery1.Parameters.ParamByName('c_id').Value:=Edit3.Text;
ADOQuery1.Parameters.ParamByName('p_id').Value:=Edit4.Text;
ADOQuery1.Open;
--------------------------------------------------------------------------
这样写对不对,应该怎样写???
解决方案 »
- delphi中ACCESS的自定义函数怎么用呢...
- 小弟是个菜鸟请问各位打下"beep"是个什么东西啊?在线等...............
- 想了很久都没有做出的问题(救急)
- 按button1时创建Access数据库及表?
- delphi窑洞怎么上不去啦???
- 关于elphi5.0 用ADO 连接sql server 2000 存储过程的问题
- DBGrid的滚动问题
- 为什么我用的batchmove的mode为batupdate模式会出错?
- 如何用Report Builder制作工资条,采用A3纸,最好能提供一些例子。
- filter 问题1
- 动态创建一个TDatabase, free后,内存怎么回收呢?
- how can I use the date which in one table to change other tables
(Edit1.Text))+''' BETWEEN shi_date and end_date)or('''+FormatDateTime('yyyy-m-d',StrToDate(Edit2.Text))
+''' BETWEEN shi_date and end_date)');