to_date 之后用between你最好能够你那个时间字段中把需要的信息提取出来,比如说你需要的年select * from a where to_date(timecolumn,'yyyyy') between to_date('2001','yyyy') and to_date('2004','yyyymmdd');

解决方案 »

  1.   

    select * from a where to_date(timecolumn,'yyyyy') between to_date('2001','yyyy') and to_date('2004','yyyy');上面写错啦,一个激动就把mmdd也带出来啦,呵呵
      

  2.   

    java里面&&的函数或运算符---是什么功能?
      

  3.   

    &&的函数或运算符-----表示功能是,举个列子:  if(a > 1 && b >1)
    如果a 不大于1的话,后面b就不用去判断了,因为这个与的条件肯定不成立了现在2004年9月23日以后的日期都是完整的,但是之前的有的只有年月,有的只有年,所以select的时候要先判断长短,不然to_date的日期格式会报错
      

  4.   

    用函数lenth(x)和decode()函数
    SQL> select decode(length('2004'),4,to_date('2004','yyyy'),7,to_date('2004-09','yyyy-mm')) from dual;DECODE(LENGTH('2004'),4,TO_DAT
    ------------------------------
    2004-10-1