想查询一个表中的日期列edate,查询要的结果是edate between '某月某日' and '某月某日'之间的数据;因为刚学习Oracle,写了一个老是说月份无效
select * from tbl_empl from edate between to_date(0112,'mmdd') and to_date(1201,'mmdd');
这个语句为什么老报月份无效异常呢??

解决方案 »

  1.   

    select * from tbl_empl from to_char(edate,'mmdd')  between '0112' and  '1201'; 
      

  2.   

    数据类型是Date类型的,对不起刚才没说清楚
      

  3.   

    tiancx82
    您写的这个还是有错 可能是我刚才没说清楚,edate类型是date类型的
      

  4.   

    oracle 日期范围查询问题 
    select * from aaa where to_char(rq,'yyyymmdd') between '20011101' and '20020301';
    直接在rq上加函数,如果应用大(这个表内数据很多时),查询速度会相当慢的,为了提高查询速度,强烈建议这样书写:
    select * from aaa where rq between to_date('2001-11-01','yyyy-MM-DD') and to_date('2002-03-01' ,'YYYY-MM-DD');
    推荐使用
    select * from aaa where rq>;=to_date('2001-11-01','yyyy-MM-DD') and rq<=to_date('2002-03-01' ,'YYYY-MM-DD');用between的函数可能会慢些
      

  5.   


    select * from tbl_empl where edate between to_date(0112,'mmdd') and to_date(1201,'mmdd');
      

  6.   

    select  *  from  table  where  rq  between(to_date(' 2010-2-10' ,' yyyy-mm-dd' ))  and  (to_date(' 2010-2-19' ,' yyyy-mm-dd' ))  select  *  from  table  where  rq> =to_date(' 2010-2-10' ,' yyyy-mm-dd' )  and  larq  < =to_date(' 2010-2-19' ,' yyyy-mm-dd' )
      

  7.   


    select * from your_table a where to_char(a.time_column,'yyyy-mm-dd') between '2010-01-01' and '2010-02-21'