我使用如下语句时,报错标准表达式类型不匹配:
AdoQuery1.Sql.Add('select * from nbsc where 签定时期 between '2003-2-1'
 and '2003-6-1'');
或者:
AdoQuery1.Sql.add('select * from nbsc where 签定日期 >='2003-2-1' and
   签定日期 <= '2003-6-1');
使用如下语句时不报错,但是查不出东西来:
AdoQuery1.Sql.Add('select * from nbsc where 签定时期 between 2003-2-1
 and 2003-6-1');
或者:
AdoQuery1.Sql.add('select * from nbsc where 签定日期 >= 2003-2-1 and
   签定日期 <= 2003-6-1);
签定日期是日期型字段,请问是怎么回事?
我按照erp2(天涯剑)老兄的方法做
AdoQuery1.Sql.add('select * from nbsc where dtoc(签定日期) >= '2003-2-1' and
   dtoc(签定日期) <= '2003-6-1');
但是报错,没有定义dtoc()这个函数,这个函数怎么引用的?或者有其他的方法?

解决方案 »

  1.   

    修改引号试一试
    AdoQuery1.Sql.add('select * from nbsc where 签定日期 >='''+'2003-2-1'+''' and
       签定日期 <= '''+'2003-6-1'+'''');
      

  2.   


    没有试过就结贴子了
    我还想告诉你方法呢
    一看都结了
    性子也未免太急了吧
    Select * from nbsc where 签定时期 between #2003-2-1
     and #2003-6-1
    或者可以用format格式化
    那个比较麻烦点 就用这个好了
      

  3.   

    我用focus(老鱼)这个方法怎么还是不行啊,报错为操作符丢失啊。
      

  4.   

    DataModule2.wbscAdo.SQL.Add('select * from wbtz where'+' '+ComboBox2.Text
                   +' '+'>='+' '+''''+Edit3.Text+'-'+ComboBox3.Text+'-1'+''''+' '+'And'+' '+ComboBox2.Text+
                   ' '+'<='+' '+''''
                   +Edit4.Text+'-'+ComBoBox4.Text+'-31'+'''');
    我这是上面这样写的ComboBox2为查询的条件字段值,我假如它为签定日期。
    Edit3和Edit4分别为年份的输入,ComboBox4和ComboBox3为月份的选择,怎么才能让它完全正确呢。
      

  5.   

    DataModule2.nbscAdo.SQL.Add('select * from nbsc where'+' '+ComboBox2.Text
                   +'>='+'#'+Edit3.Text+'-'+ComboBox3.Text+'-1'+' '+'And'+' '+ComboBox2.Text+
                   ' '+'<='+'#'+Edit4.Text+'-'+ComBoBox4.Text+'-31');
    我改成这样也还是不行也!
      

  6.   

    DataModule2.nbscAdo.SQL.Add('select * from nbsc where'+' '+ComboBox2.Text
                   +'>='+' '+'#'+Edit3.Text+'-'+ComboBox3.Text+'-1'+'#'+' '+'And'+' '+ComboBox2.Text+
                   ' '+'<='+' '+'#'+Edit4.Text+'-'+ComBoBox4.Text+'-31'+'#');
    这样也不行啊。