数据库保存的是date类型的吗?

解决方案 »

  1.   

    注意你的时间格式,oracle 的sql语句对这个很苛刻的
    最好是把你的源程序写出来描一下。
      

  2.   

    不好意思,今天才来回贴。
    SQL语句如下:
    select a.*,b.work_order_number,b.priority_code,c.customer_part_number,
    d.dept_code,d.dept_name
    from plan_stepitem a,data0006 b,data0050 c,data0034 d
    where a.wo_ptr=b.rkey
    and b.cust_part_ptr=c.rkey
    and a.dept_ptr=d.rkey
    and a.defer_time>0
    and a.ttype=0
    and d.dept_code like :dept_code
    and c.customer_part_number like :customer_part_number
    and to_date(to_char(a.sch_compl_date,'YYYY-MM-DD'),'YYYY-MM-DD')        
        between :date_from and :date_to 
    程序如下:
        With Query1 Do
        Begin
          if Active Then
            Close;
          ParamByName('date_from').Value:=DateTimePicker1.Date;
          ParamByName('date_to').Value:=DateTimePicker1.Date;
          ParamByName('dept_code').asstring:=Edit6.Text+'%';
          ParamByName('customer_part_number').asstring:=Edit7.Text+'%';
          Open;
        End;
      

  3.   

    你的date_from和date_to参数的时间格式和to_date()函数的格式不一致,
    你必须保证date_from 也是YYYY-MM-DD的格式才能比较.
      

  4.   

    如果a.defer_time是date类型的
    a.defer_time>0,这样用是错误的
    改成
    a.defer_time is not null
      

  5.   

    dtliupeng(吉利) ,bzszp(SongZip):
    不是啊,执行起来都是没问题的,数据也查出来了,但是如果你滚动DBGrid时,有时就会出来上述错误了,是不是基其中的某条记录有问题呢?