Warning: count(): Parameter must be an array or an object that implements Countable in /membri/oraclefaq/qa-include/app/format.php on line 384
Funzione plsql per il calcolo del giorno di Pasquetta - Oracle FAQ - Il forum italiano su oracle
0 voti
3.2k visite
quesito posto in SQL e PLSQL da (2.4k punti)
Funzione trovata in rete che restituisce, dato l'anno in ingresso, in che giorno cade la Pasquetta.

FUNCTION getPasquetta(p_anno IN POSITIVEN)
RETURN DATE IS
 
   a      INTEGER;
   b      INTEGER;
   c      INTEGER;
   d      INTEGER;
   e      INTEGER;
   f      INTEGER;
   g      INTEGER;
   h      INTEGER;
   i      INTEGER;
   j      INTEGER;
   k      INTEGER;
   l      INTEGER;
   m      INTEGER;
   mese   INTEGER;
   giorno INTEGER;
    
BEGIN
   a := p_anno MOD 19;
   b := trunc(p_anno / 100);
   c := p_anno MOD 100;
   d := trunc(b / 4);
   e := b MOD 4;
   f := trunc((b + 8) / 25);
   g := trunc((b - f + 1) / 3);
   h := (19 * a + b - d - g + 15) MOD 30;
   i := trunc(c / 4);
   j := c MOD 4;
   k := (32 + e + e + i + i - h - j) MOD 7;
   l := trunc((a + 11 * h + 22 * k) / 451);
   m := h + k - 7 * l + 114;

   giorno := (m MOD 31) + 1;
   mese   := trunc(m / 31);
   RETURN to_date(to_char(giorno) || '/' || to_char(mese) || '/' || to_char(p_anno), 'dd/mm/yyyy') + 1;
END getPasquetta;

Viene calcolato prima il giorno di Pasqua a cui viene poi aggiunto un giorno.

La funzione può tornare molto utile soprattutto se si ha la necessità di calcolare il numero di giorni lavorativi.

Fai il log in oppure registrati per rispondere al quesito.

Domande correlate


Warning: count(): Parameter must be an array or an object that implements Countable in /membri/oraclefaq/qa-include/app/format.php on line 384

Warning: count(): Parameter must be an array or an object that implements Countable in /membri/oraclefaq/qa-include/app/format.php on line 384

Warning: count(): Parameter must be an array or an object that implements Countable in /membri/oraclefaq/qa-include/app/format.php on line 384

Warning: count(): Parameter must be an array or an object that implements Countable in /membri/oraclefaq/qa-include/app/format.php on line 384

Warning: count(): Parameter must be an array or an object that implements Countable in /membri/oraclefaq/qa-include/app/format.php on line 384
0 voti
0 risposte 1.3k visite
0 voti
0 risposte 20.5k visite
quesito posto 3 Dicembre 2013 in SQL e PLSQL da carlo10 (2.4k punti)
0 voti
0 risposte 1.1k visite
quesito posto 4 Dicembre 2013 in SQL e PLSQL da carlo10 (2.4k punti)
0 voti
0 risposte 114 visite
0 voti
0 risposte 3.2k visite
...