## RVY_ISANNEESCOLAIRE

Doc
Details
Grants
References
Dependencies
Code

TEXT
    FUNCTION RVY_ISANNEESCOLAIRE(ANNEE_CIVILE NUMBER, SEMAINE NUMBER) RETURN NUMBER IS
       result NUMBER;
       mois NUMBER;
       annee NUMBER;
       creneau DATE;
    BEGIN
       SELECT to_number(to_char(sysdate,'MM')) INTO mois FROM DUAL;
       SELECT to_number(to_char(sysdate,'RRRR')) INTO annee FROM DUAL;
       SELECT RVY_ARELTODATE(ANNEE_CIVILE,SEMAINE,0,'01h00') INTO creneau FROM DUAL;
       IF mois<9 THEN
          SELECT
             COUNT(*) INTO result
          FROM
             DUAL
          WHERE
             creneau>to_date((annee-1)||'-09-01','RRRR-MM-DD') AND
             creneau<to_date((annee)||'-08-31','RRRR-MM-DD');
       ELSE
          SELECT
             COUNT(*) INTO result
          FROM
             DUAL
          WHERE
             creneau>to_date((annee)||'-09-01','RRRR-MM-DD') AND
             creneau<to_date((annee+1)||'-08-31','RRRR-MM-DD');
       END IF;
       RETURN result;
    END;