select * from tbname where ddsendtime between to_date('2005-01-01','yyyy-mm-dd')
and to_date('2005-02-01','yyyy-mm-dd');

解决方案 »

  1.   

    To bzszp(SongZip):
    版主,如果是to_date,那么ddsendtime字段小时分秒就没有记录了
      

  2.   

    select * 
    from table_name
    where truncate(ddsendtime)> to_date('2004-08-17','yyyy-mm-dd')
    and truncate(ddsendtime)<=to_date('2004-08-19','yyyy-mm-dd')
      

  3.   

    select * from table1 where ddsendtime between to_date('xxxxxxxx','yyyymmdd') and to_date('xxxxxxxx','yyyymmdd');
      

  4.   

    请问这条存储过程那里有错误?
    proc.......(pcstarttime in varchar2.pcendtime in varchar2);
    as
    ipcstarttime date;
    ipcendtime date;
    csql varchar(2000);
    begin
      ipcstarttime:=to_date(pcstarttime,'yyyy-mm-dd hh24:mi:ss')
      ipcendtime :=to_date(pcendtime,yyy-mm-dd hh24:mi:ss')
      sql:=select .... from ... where  ddsendtime>ipcstarttime and ddsendtime <iendtime;end;
    在这里between ... and ... 也不能用
    分数只给解答对问题的人?
      

  5.   

    老大,如果你的程序代码没拷错的话,
    是语法错,
    “ipcstarttime:=to_date(pcstarttime,'yyyy-mm-dd hh24:mi:ss')”没有“;”
    .....
      

  6.   

    在存储过程里执行select要有返回值,
    你的那个sql查询没有返回给变量嘛。
    单记录返回给变量,多条记录返回给游标......
      

  7.   

    这是正确的写法,一定要注意日期格式的转换。
    create or replace procedure Pr_Temp (pcstarttime in varchar2,pcendtime in varchar2)
    is
    ipcstarttime date;
    ipcendtime date;
    csql varchar(2000);
    begin
      ipcstarttime:=to_date(pcstarttime,'yyyy-mm-dd hh24:mi:ss');
      ipcendtime :=to_date(pcendtime,'yyyy-mm-dd hh24:mi:ss');
      
      csql:='select * from HOLIDAY_INFO where  BEGINDATE >''' || ipcstarttime ||''' and BEGINDATE < ''' || ipcendtime ||'''';
      execute immediate csql;end;