Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Possible to compare date with easter (or any other holiday) with sql?
Ok, I was bored...
create or replace function easter (year integer)
return date is
g pls_integer; c pls_integer; x pls_integer; z pls_integer; d pls_integer; e pls_integer; n pls_integer;
begin
g := mod(year, 19) + 1; c := trunc((year / 100) + 1); x := trunc(((3 * c) / 4) - 12); z := trunc(((8 * c + 5) / 25) - 5); d := mod(trunc(((5 * year) / 4) - x - 3), 7); e := mod((11 * g + 20 + z - x), 30); if (e = 25 and g > 11) or e = 24 then e := e + 1;
n := 44 - e;
if n < 21 then
n := n + 30;
end if;
n := n + 7 - mod(d + n, 7);
return to_date('01-MAR-' || year, 'DD-MON-YYYY') + n - 1;
end easter;
/
Sybrand Bakker wrote:
>
> On 2 May 2002 08:03:17 -0700, marcel.kraupp_at_gmx.ch (Marcel Kraupp)
> wrote:
>
> >Hello
> >
> >Is there an easy (or not so easy) way that allows me to compare a date
> >with easter (or any ohter holiday such as pentecost, thanksgiving and
> >so on)?
> >
> >I appreciate any help.
> >
> >Marcel
>
> I'm not sure whether it is possible to implement the algorithm of
> Father Clavius to determine the Easter date can be implemented in
> (pl/)sql, as there is quite some arithmetic. I have this algorithm on
> an old PC without monitor and keyboard, but you also might find it on
> the web. Father Clavius devised the algorithm on order of Pope Gregory
> for his calendar reform of 1582.
> Pentecost is 50 days after Easter, the meaning of the word is 'The
> 50th day'
>
> You may find the algorithm of Father Clavius on
>
> http://www.shef.ac.uk/~puremath/theorems/easter.html
>
> As usual Google helped here
>
> Hth
>
> Sybrand Bakker, Senior Oracle DBA
>
> To reply remove -verwijderdit from my e-mail address
Received on Thu May 02 2002 - 14:10:01 CDT