"select * from t_ct22b_1 where to_char(xcrq,'yyyymmdd')='20020202'"

解决方案 »

  1.   

    rs1.Open "select * from t_ct22b_1 where xcrq like '02-02-02'"
    这句话写错了!应该是这样:
    rs1.Open "select * from t_ct22b_1 where to_char(xcrq,'yyyy-mm-dd') like '2002-02-02'"
      

  2.   

    同意。
    字段xcrq是日期型的,要先转换成字符型。
      

  3.   

    "select * from t_ct22b_1 where to_char(xcrq,'yyyy-mm-dd')='2002-02-02'"
      

  4.   

    为什么要用字符型来比较呢,速度比较慢,日期型比较速度快,特别是有索引的时候,还有,为什么要用like呢,我觉得可以用 = 的
    "select * from t_ct22b_1 
    where trunc(xcrq)=to_date('2002-02-02','yyyy-mm-dd')"