ejbql = "select object(p) from P3gjdxb as p where p.pid = '" + p1 + "' and p.rq between to_date("+p2+",'yyyymmdd') and to_date("+p3+",'yyyymmdd') orderby p.pid,p.bm,p.rq";

解决方案 »

  1.   

    select object(p) from P3gjdxb as p where p.pid = '1' and p.rq >= '1970-01-01'
     and p.rq<='2004-01-01' order by p.pid,p.bm,p.rq
      

  2.   

    751003(ccb) 所使用的方法,在执行时提示 to_date不能使用, mtou(逆风) 所使用的方法,在执行时还是提示java.sql.SQLException: ORA-01861: 文字与格式字符串不匹配。我该怎么办呀?
      

  3.   

    难道用 Date 类不行吗?? ------------------------------------------------------
               我们还年轻牛奶会有的奶牛也会有的 
                 可天天在 csdn 混这些会有吗 ??
      

  4.   

    可以这样:
    java.text.SimpleDateFormat sdf = new  java.text.SimpleDateFormat("yyyy-MM-dd");
    String strDate1 = sdf.format(p2);
    String strDate2 = sdf.format(p3);
    然后在sql里面直接用between '"+strDate1+"' and '"+strDate2+"'
    至于日期的其它格式你可以看看SimpleDateFormat的document
      

  5.   

    to zez(思恩 为老婆多挣钱 鹤清风),用那个Date类呢?如何处理?能给出具体代码吗?
    现在的代码:(jb环境)
     String a2 = "1999-01-01";
     java.text.SimpleDateFormat sdf = new  java.text.SimpleDateFormat("yyyy-MM-dd");
     java.util.Date d1 = sdf.parse(a2);
     String strDate1 = sdf.format(d1);
     ejbql = "select object(p) from P3gjdxb as p where p.pid = '" + a1 + "' and p.rq >= '"+strDate1+"' orderby p.pid,p.bm,p.rq";