## Aflare data Paste catolic pentru un anumit an

Configurare noua (How To)

### Situatie

Mai jos este o functie ce primeste ca parametru un an calendaristic, iar pentru acel an returneaza data in care se va sarbatori Pastele Catolic.

### Solutie

— select dbo.CalculDataPasteCatolic(2022)

CREATE FUNCTION dbo.CalculDataPasteCatolic(@inYear int)
RETURNS datetime
AS
BEGIN
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

Permanent
Etichetare:

### Voteaza

(7 din 16 persoane apreciaza acest articol)