Follow Us on Twitter

Ascension today, PL/SQL algorithm to calculate Easter Sunday

by Jan Thuis on May 13, 2010 · 3 comments

Easter Sunday is always the first Sunday after the first full moon after March 21 (early spring). Numerous festivals are related to Easter, including on the date they are celebrated. This varies from Carnival (7 weeks before Easter) until Pentecost (7 weeks after Easter). This also applies to Ascension (40 days after Easter). Read more on Wikipedia.

Previously, people wake up on Ascension at three hours at night and wake up to singing and dance barefoot on the grass. Hence the Dutch word ‘dauwtrappen’. The dew on the grass would have a purifying effect. ‘Dew Walking’ is currently, especially in the east of the Netherlands, a tradition. Instead of singing and dancing on the grass, one makes a hike or bike ride.

Because the weather today is not really great, I decided to clean up my hard drive. I found a nice algorithm to calculate Easter Sunday which I’ve used in a holiday administration system.

create or replace
function eastersunday(p_year number default to_number(to_char(sysdate,'RRRR')))
  return date is
/*
||  Jan Thuis,   April 2004
||  Calculate the date of Easter Sunday
||
||  Gregorian method (any year since 1583) based on algorithm of Oudin
*/
  l_eastersunday date;
  l_g integer;
  l_c integer;
  l_d integer;
  l_e integer;
  l_h integer;
  l_k integer;
  l_p integer;
  l_q integer;
  l_i integer;
  l_j integer;
  l_x integer;

begin
  l_g := mod(p_year,19);
  l_c := floor(p_year/100);
  l_d := l_c - floor(l_c/4);
  l_e := floor((8 * l_c + 13)/25);
  l_h := mod(l_d - l_e + 19 * l_g + 15 ,30);
  l_k := floor(l_h / 28);
  l_p := floor(29/(l_h + 1));
  l_q := floor((21 - l_g)/11);
  l_i := l_h - l_k * (1 - l_k * l_p * l_q);
  l_j := mod((p_year + floor(p_year/4 + l_i + 2 - l_d )),7);
  l_x := 28 + l_i - l_j;
  l_eastersunday := to_date('0103'||p_year,'DDMMYYYY') + l_x -1;

  return l_eastersunday;
end eastersunday;

To calculate the next Eastern Sunday:

select eastersunday(2011) from dual
Ascension today, PL/SQL algorithm to calculate Easter Sunday, 5.0 out of 5 based on 1 rating

Ratings:
VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)

{ 3 comments… read them below or add one }

Ytzen May 14, 2010 at 10:23 am

nice gadget

Reply

fortius December 2, 2010 at 3:00 pm

Finally I found some algoritm for easter whitch is working, Thank you.

Reply

bill January 4, 2011 at 5:27 pm

SUPER! It works great!

Reply

Leave a Comment

 

Previous post:

Next post:

About Whitehorses
Company profile
Services
Technology

Whitehorses website

Home page
Whitebooks
Jobs

Follow us
Blog post RSS
Comment RSS
Twitter