表A
  fid    name     birth
   1     aaa      2009-09-28
   2     bbb      2009-09-29
birth是生日日期,当前日期是2009-09-25
提前3天提醒,这个语句怎么写?即查询三天后的记录如今天日期是2009-09-25
查询三天后的记录,结果 是
1     aaa      2009-09-28

解决方案 »

  1.   

    SELECT * FROM A WHERE birth = TO_CHAR(sysdate+3,'yyyy-mm-dd')
      

  2.   

    select * from a
    where birth between to_char(sysdate,'yyyy-mm-dd') and to_char(sysdate+3,'yyyy-mm-dd')
      

  3.   

    select * 
    from A 
    where trunc(birth)-trunc(sysdate)=3; 
      

  4.   

    select * 
    from A 
    where trunc(birth)-trunc(sysdate)=3; 
      

  5.   

    select * from A where to_char(birth,'yyyy-mm-dd')=to_char(sysdate+3,'yyyy-mm-dd')
      

  6.   

    是要小于3天还是只要等于3天的数据呢
    支持下面这种,当然要求你的birth字段是日期select * 
    from A 
    where trunc(birth)-trunc(sysdate)=3; 
      

  7.   


      select * from ta
      where to_char(birth,'YYYY-MM-DD') = to_char(sysdate+3,'YYYY-MM-DD')