Thursday, 18 July 2013

Ger the financial year in pl/sql

function GET_FISCAL_YR
return number
is
    v_date    date;
    v_month   varchar2(2);
    v_year    varchar2(4);
   
begin

    v_date := sysdate;

    select to_char(v_date, 'MM'), to_char(v_date, 'YYYY') 
    into   v_month, v_year
    from   dual;
   

    if v_month > '03' then
       return (v_year+1);
    else
       return (v_year);
    end if;
   
end GET_FISCAL_YR;

No comments:

Post a Comment