Technical Article

Determine Easter Sunday

,

SELECT dbo.HRF_FN_FIND_EASTER_SUNDAY (2016)

This is uesfull if you need to know what dates will be long weekend in the future.

Create FUNCTION [dbo].[KDT_FN_FIND_EASTER_SUNDAY](@inYear int)
RETURNS datetime
AS
BEGIN
/*
  CREATED BY Kraai
  
  E.G OF USE : SELECT dbo.KDT_FN_FIND_EASTER_SUNDAY (2016)
  PURPOSE: 
  DETERMININING THE EASTER SUNDAY AS PER THE WESTERMN CREGORIAN CALENDAR THIS IS HELPFULL AS GOOD FRIDAY IS ALWAYS THE FRIDAY BEFORE THIS SUNDAY AND IN SA FAMILY DAY IS ALWAYS THE MONDAY 
  
  MORE INFORMATION ON CALCULATING EASTER ETC CAN BE FOUND : http://www.assa.org.au/edm.html#Method
  
  SHORT HISTORY OF EASTER DATE : 

Easter Sunday is the Sunday following the Paschal Full Moon (PFM) date for the year.   (Paschal is pronounced "PAS-KUL", not "pas-chal").   See Christian Prayer Books for proof of this concise definition.

In June 325 A.D. astronomers approximated astronomical full moon dates for the Christian church, calling them Ecclesiastical Full Moon (EFM) dates.   From 326 A.D. the PFM date has always been the EFM date after March 20 (which was the equinox date in 325 A.D.)

From 1583, each PFM date differs from an Astronomical Full Moon (AFM) date usually by no more than 1 date, and never by more than 3 dates.   (Each AFM is a two-dates event due to world time zones.   Each PFM is a one-date event world-wide).


*/    DECLARE @dtNow datetime
    DECLARE @inCurDay int
    DECLARE @inCurMonth int
    DECLARE @inCurYear int
    DECLARE @inCurCent int
    DECLARE @inYear19 int
    DECLARE @inYearTmp int
    DECLARE @inTemp2 int
    DECLARE @inTemp3 int
    DECLARE @inTemp4 int
    DECLARE @inEastDay int
    DECLARE @inEastMonth int
    DECLARE @dtEasterSunday datetime

    SET @dtNow = CONVERT(datetime,CAST(@inYear as char(4))+'-01-01')

    SET @inCurDay=DAY(@dtNow)
    SET @inCurMonth=MONTH(@dtNow)
    SET @inCurYear=YEAR(@dtNow)
    SET @inCurCent=FLOOR(@inCurYear/100)

    SET @inYear19=@inCurYear%19

    SET @inYearTmp=FLOOR((@inCurCent-17)/25)
    SET @inTemp2=(@inCurCent-FLOOR(@inCurCent/4)-FLOOR((@inCurCent-@inYearTmp)/3)+(19*@inYear19)+15)%30
    SET @inTemp2=@inTemp2-FLOOR(@inTemp2/28)*(1 - FLOOR(@inTemp2/28)*FLOOR(29/(@inTemp2+1))*FLOOR((21-@inYear19)/11))

    SET @inTemp3 = (@inCurYear+FLOOR(@inCurYear/4)+@inTemp2+2-@inCurCent+FLOOR(@inCurCent/4))%7
    SET @inTemp4 = @inTemp2-@inTemp3

    SET @inEastMonth = 3+FLOOR((@inTemp4+40)/44)
    SET @inEastDay = @inTemp4+28-31*FLOOR(@inEastMonth/4)
    SET @inEastMonth = @inEastMonth - 1

    SET @dtEasterSunday = CONVERT(datetime,CAST(@inCurYear as varchar(4))+'-'+RIGHT(CAST('00' as varchar(2))+CAST(@inEastMonth+1 as varchar(2)),2)+'-'+RIGHT(CAST('00' as varchar(2))+CAST(@inEastDay as varchar(2)),2)+' 00:00:00')
    RETURN @dtEasterSunday
END

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating