26 Apr 2018

Hijri Calendar Function

CREATE OR REPLACE FUNCTION GET_HIJRI_DATE(P_GEORGIN_DATE IN DATE, P_DAY IN NUMBER DEFAULT -1) 
RETURN VARCHAR2 IS 
  V_TDATE DATE :=P_GEORGIN_DATE; 
  V_RESULT VARCHAR2(500); 
  V_FINAL VARCHAR2(1000);
BEGIN 

   V_TDATE :=V_TDATE + NVL(P_DAY,-1); 
    SELECT TO_CHAR(V_TDATE,'FMDD-MONTH-YYYY','NLS_CALENDAR=''ENGLISH HIJRAH''') 
    INTO V_RESULT FROM DUAL; 
     V_FINAL :='Georgin Date Is '||V_TDATE||CHR(10)||'Hijri Date Is ' ||V_RESULT; 
     RETURN(V_FINAL); 
END;

In Parameter P_Day User Provide There Country Islamic Days which may be -1 or +1 With Saudi Islamic Calendar.

INPUT 
  SELECT GET_HIJRI_DATE(SYSDATE) FROM DUAL;OUTPUT