select * from table where int((month(日期字段)-1)/3)+1 = int((month(your_date)-1)/3)+1

解决方案 »

  1.   

    将日期格式花只提取出月份month
    然后,month/3取整 设为n
    那个季度就是(n*3+1)到(n*3+3)
    再把两个端点日期求的
    select * from table_name where date_column between  date_end1 and date_end2
      

  2.   

    SQL> select month(to_date('2002/01/01','yyyy-mm-dd')) from dual;select month(to_date('2002/01/01','yyyy-mm-dd')) from dualORA-00904: invalid column name
    怎么回事?难道不能这样用month含数?
      

  3.   

    CREATE OR REPLACE PACKAGE pkg_test
    AS
       TYPE myrctype IS REF CURSOR;
    END pkg_test;
    /
    create procedure get_date(p_date in date,p_rc out pkg_test.myrctype)
    as
    begin
    if to_char(p_date,'q')=1 then
    str:='select * from col_date between trunc(p_date,'yyyy') and add_months(trunc(p_date,'yyyy'),3)';
    elsif to_char(p_date,'q')=2 then
    str:='select * from col_date between add_months(trunc(p_date,'yyyy'),3) and add_months(trunc(p_date,'yyyy'),6)';
    elsif to_char(p_date,'q')=3 then
    str:='select * from col_date between add_months(trunc(p_date,'yyyy'),6) and add_months(trunc(p_date,'yyyy'),9)';
    else 
    str:='select * from col_date between add_months(trunc(p_date,'yyyy'),9) and (add_months(trunc(p_date,'yyyy'),12)+30)';
    end if;
    open p_rc for str;
    end;
    /
      

  4.   

    不明to_char(p_date,'q')=1 是什么意思;
     beckhambobo(beckham) 贝哥,能否说明一下该程序?
      

  5.   

    Q  No Quarter of year (1, 2, 3, 4; JAN-MAR = 1),to_char(p_date,'Q') 得到的是季节数
      

  6.   

    select * from dkhinfo  where to_char(column_date,'q') = to_char(input_date,'q')