有一个视图:vw_table
create or replace view vw_table as
select t.*,to_number(to_date(p.end_date,'yyyy-mm-dd')-to_date(to_char(sysdate,'yyyy-mm-dd'),'yyyy-mm-dd')) balanceDate
from t,p
where t.en_id=p.en_id
order by p.glo_id desc然后写sql语句:
select * from vw_table t where t.balanceDate=363总提示说:指定月份的日期无效不知道为什么?应该怎么解决呢?

解决方案 »

  1.   

    两个date类型相减 就是一个NUMBER 不用再to_number了
      

  2.   

    是的,但就是不用to_number,那条sql语句也会出错啊!!!!
      

  3.   

    可以简写为:create or replace view vw_table as
    select t.*,(to_date(p.end_date,'yyyy-mm-dd')-sysdate) balanceDate
    from t,p
    where t.en_id=p.en_id
    order by p.glo_id desc
    你的指定月份无效可能是P.END_DATE里面的值的问题.它是字符型的吗???
      

  4.   

    找到问题了,是p.end_date里面一条记录有问题