Computus - Easter Sunday in SQL Server 2005

Working on an article about an auxiliary calendar table I needed to find a routine for calculating Easter Sunday. Many years ago I made my Delphi routine for this, and haven't really thought much about it since. Reading an article about calendar tables I found a function doing the trick. I tested the routine and it happened to fail so I needed to find another one. Luckily today we have wikipedia, something we didn't 10 years ago when I found my last Easter Sunday function.

From Wikipedia: Computus (Latin for computation) is the calculation of the date of Easter in the Christian calendar.
In the article I found the Meeus/Jones/Butcher Gregorian algorithm that is supposed to work for any Easter ever in the Gregorian calendar.

CREATE FUNCTION [Auxiliary].[Computus]
@Y INT -- The year we are calculating Easter Sunday for

@a INT,
@b INT,
@c INT,
@d INT,
@e INT,
@f INT,
@g INT,
@h INT,
@i INT,
@k INT,
@m INT

@a = @Y % 19
SET @b = @Y / 100
SET @c = @Y % 100
SET @d = @b / 4
SET @e = @b % 4
SET @f = (@b + 8) / 25
SET @g = (@b - @f + 1) / 3
SET @h = (19 * @a + @b - @d - @g + 15) % 30
SET @i = @c / 4
SET @k = @c % 4
SET @L = (32 + 2 * @e + 2 * @i - @h - @k) % 7
SET @m = (@a + 11 * @h + 22 * @L) / 451
RETURN(DATEADD(month, ((@h + @L - 7 * @m + 114) / 31)-1, cast(cast(@Y AS VARCHAR) AS Datetime)) + ((@h + @L - 7 * @m + 114) % 31))

I got no clue about the intricacy of this math. But it works and that's fine for me :-)

Next: "The Auxiliary Calendar Table For SQL Server 2005" ...


Anonymous said...

Hello [url=http://girlsonnet.blogspot.com]sexy girls[/url] | [url=http://sexcam-.blogspot.com]sexy webcam videos[/url] | [url=http://www.blogigo.de/livechat]live chat[/url] [url=http://xanaxxx.blogspot.com]xanax cheap[/url] [url=http://xanax-info-.blogspot.com]xanax buy[/url] [url=http://xanax-top.blogspot.com] xanax online[/url] [url=http://phentermine-top.blogspot.com]phentermine buy[/url] [url=http://phentermineee.blogspot.com]phentermine online[/url] [url=http://pphentermine.blogspot.com]phentermine cheap[/url] [url=http://tramadol-top.blogspot.com]tramadol buy[/url] [url=http://tramadoldol.blogspot.com]tramadol online[/url] [url=http://tramadol-pret.blogspot.com]tramadol cheap[/url] [url=http://levaquin-top.blogspot.com]levaquin buy[/url] [url=http://levaquinn.blogspot.com]levaquin online[/url] [url=http://ilevaquin.blogspot.com]levaquin cheap[/url] [url=http://norvasc-top.blogspot.com]lnorvasc buy[/url] [url=http://babylon-xxx.blogspot.com]sex online[/url]
[url=http://babylon1.blogspot.com]babe online[/url] [url=http://casino-lasvegas.blogspot.com]casino online[/url] [url=http://casino-usa.blogspot.com]casino online[/url] [url=http://roulette-zero.blogspot.com]lroulette online[/url] [url=http://blackjack06.blogspot.com]blackjack online[/url] [url=http://poker-shmokker.blogspot.com]lpoker online[/url] [url=http://phentermine.aliasy.org]phentermine online[/url] [url=http://hometown.aol.com/BuyXanaxO/XANAX.html]xanax[/url] [url=http://hometown.aol.com/BuyXanaxO/BUYXANAX.html]xanax buy[/url] [url=http://hometown.aol.com/BuyXanaxO/PHENTERMINE.html]phentermine[/url] [url=http://hometown.aol.com/BuyXanaO/BUYPHENTERMINE.html]phentermine buy[/url] [url=http://hometown.aol.com/BuyXanaxO/PHENTERMINECHEAP.html]phentermine cheap[/url] | [url=http://www.blogigo.de/livechat]live chat[/url]
for fun

Anonymous said...

live chat Good job.....thanks.....Must be a reason to find friends in your area! Try this page....

Anonymous said...

Hi. Use this search engine for best result: BDsearch Find all you need in your area!

Anonymous said...

I welcome you!
The given place is privatized by sex and health! Whether probably for health to correct good sex?!
Welcome to sexy teens | movie pages | picture pages | webcam movie | adult friend finder.
Here pages devoted to health are published.
It is the large search robot, which can help to receive this or that information and as to get this or that goods! Tramadol | Phentermine | Buy Xanax | Xanax and all that is necessary.
See you soon!

Anonymous said...

You won’t believe your eyes, see the World’s best girls HERE! ...... Try to find sexy partner in your area !
- JOIN FREE - After free registration you can have unlimited access to the huge adult source.
ATTANTION ! Adult only !...... http://searchchat0.tripod.com