How to get remaining months in a fiscal year in Oracle HRMS Payroll

PL-SQL Function below returns the number of months remaining in a fiscal year excluding current month.


CREATE OR REPLACE FUNCTION APPS.CUST_GET_MONTHS_REMAINING (P_DATE DATE ) RETURN NUMBER IS
/*
    PROGRAM ID      :   APPS.CUST_GET_MONTHS_REMAINING
    DESCRIPTION     :   RETURN MONTHS REMAINING TO END OF FISCAL YEAR.
   
*******************************************************************************************
*/  
 THIS_YEAR NUMBER;
 BEGIN
      
    IF TO_NUMBER(TO_CHAR(P_DATE,'MM')) > 6 AND TO_NUMBER(TO_CHAR(P_DATE,'MM')) < 12    THEN
        RETURN (12-TO_NUMBER(TO_CHAR(P_DATE,'MM')))+6;
    ELSE
        RETURN 6-TO_NUMBER(TO_CHAR(P_DATE,'MM'));
    END IF;
   
END;
/



0 comments: