Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with [Years] as ( /*Generate list of years between 1900 and 2099*/
- select (ones.n + 10 * tens.n + 100 * hundreds.n + 1000 * thousands.n) [Year]
- from
- (values(0),(1),(2),(3),(4),(5),(6),(7),(8),(9)) ones(n)
- , (values(0),(1),(2),(3),(4),(5),(6),(7),(8),(9)) tens(n)
- , (values(0),(1),(2),(3),(4),(5),(6),(7),(8),(9)) hundreds(n)
- , (values(0),(1),(2),(3),(4),(5),(6),(7),(8),(9)) thousands(n)
- where (ones.n + 10 * tens.n + 100 * hundreds.n + 1000 * thousands.n) between 1900 and 2099
- ), [EasterDates] as ( /*Calculate Easter's Date from Year, https://en.wikipedia.org/wiki/Computus*/
- select (
- select (convert(date, rtrim([Year]) + '0' + rtrim([Month]) + right('0' + rtrim([Day]),2))) [Date]
- from (
- select [Month], ([DaysToSunday] + 28 - (31 * ([Month] / 4))) [Day]
- from (
- select (3 + ([DaysToSunday] + 40) / 44) [Month], [DaysToSunday]
- from (
- select ([Paschal] - (([Year] + [Year] / 4 + [Paschal] - 13) % 7)) [DaysToSunday]
- from (
- select ([Epact] - ([Epact] / 28)) [Paschal] /*https://en.wikipedia.org/wiki/Paschal_full_moon*/
- from (
- select ((24 + 19 * ([Year] % 19)) % 30) [Epact] /*https://en.wikipedia.org/wiki/Epact*/
- ) as e
- ) as p
- ) as dts
- ) as m
- ) as d) [Date]
- from [Years]
- )
- select * from [EasterDates]
Add Comment
Please, Sign In to add comment