select * from sn where date_field between to_date('20030508','yyyymmdd') and to_date('20030513','yyyymmdd');

解决方案 »

  1.   

    select * from sn where to_char(date_field,'YYYY-MM-DD') between '2003-5-8' and '2003-5-13';
      

  2.   


    select * from sn where to_char(date_field,'YYYYMMDD') between '20030508' and '20030513';
      

  3.   

    to_char(field_date,’YYYY-MM-DD’) select * from sn where to_char(date_field,'YYYY-MM-DD') between '2003-5-8' and '2003-5-13';
      

  4.   

    把字段和参数转换成一样的格式
    转换成字符:   To_Char(字段,格式)
    转换成日期:   To_Date(字段,格式)
    格式:    'YYYY-MM-DD'   ,'YYYYMMDD','YYYYMM' 等
      

  5.   

    如果date_field有建立索引,建议sql语句如下:
    select * from sn 
    where date_field>=to_date('2003-05-08', 'YYYY-MM-DD') 
      and date_field<to_date('2003-05-14', 'YYYY-MM-DD');即5.8之后到5.14之前
      

  6.   

    select * FROM sn
    where to_char(to_date(data_filed,'YYYY-MM-DD'),'YYYY-MM-DD') between '2003-05-08'
           and '2003-05-14';