I have an application written in c# that cannot run on a public holiday or a weekend. I\'ve looked around a bit and haven\'t found anywhere (official) that provides all the
In some countries (i.e. in Poland) number of holidays deepens on Easter.
At the end of this post you can find a code to calculate eater date and few holidays that depends on it.
Non-movable holidays, that are i.e. January 1st, Christmas Holidays, Independence day etc. can be stored somewhere in table.
Bear in mind that in number countries you have regions/states that can have additional public holidays, but to calculate all holidays for your country or region should be possible.
In UK i.e. you have Bank holidays that have some rules you can use in your code. - First Monday of May - Last Monday of May - Last Monday of August etc.
Please check this link for more details http://en.wikipedia.org/wiki/Public_holidays_in_the_United_Kingdom
How to calculate Easter date in SQL:
http://www.smart.net/~mmontes/nature1876.html
http://ghiorzi.org/easterda.htm
declare @a int
declare @b int
declare @c int
declare @d int
declare @e int
declare @f int
declare @g int
declare @h int
declare @i int
declare @j int
declare @k int
declare @l int
declare @m int
declare @n int
declare @Year int
declare @Month int
declare @Day int
declare @EasterSunday datetime
declare @EasterMonday datetime
declare @Pentecost datetime
declare @CorpusChristi datetime
SET @Year = 2014
SET @a = @Year%19;
SET @b = @Year/100;
SET @c = @Year%100;
SET @d = @b/4;
SET @e = @b%4;
SET @f = @c/4;
SET @g = @c%4;
SET @h = (@b + 8)/25;
SET @i = (@b - @h + 1)/3;
SET @j = (19*@a + @b - @d - @i + 15) % 30;
SET @k = (32 + 2*@e + 2*@f - @j - @g) % 7;
SET @m = (@a + 11*@j + 22*@k) / 451;
SET @n = @j + @k - 7*@m + 114;
SET @Month = @n/31;
SET @Day = (@n % 31) + 1;
--PRINT @Year
--PRINT @Month
--PRINT @Day
SET @EasterSunday = dateadd(month,((@Year-1900)*12)+@Month-1,@Day-1)
SET @EasterMonday = dateadd(day,1,@EasterSunday)
SET @Pentecost = dateadd(day,49,@EasterSunday)
SET @CorpusChristi = dateadd(day,60,@EasterSunday)
PRINT 'Easter Sunday: ' + CONVERT(VARCHAR, @EasterSunday,120) + ' [' + DATENAME(dw, @EasterSunday) + ']'
PRINT ''
PRINT 'Easter Monday: ' + CONVERT(VARCHAR, @EasterMonday,120) + ' [' + DATENAME(dw, @EasterMonday) + ']'
PRINT ''
PRINT 'Pentecost: ' + CONVERT(VARCHAR, @Pentecost,120) + ' [' + DATENAME(dw, @Pentecost) + ']'
PRINT ''
PRINT 'CorpusChristi: ' + CONVERT(VARCHAR, @CorpusChristi,120) + ' [' + DATENAME(dw, @CorpusChristi) + ']'
PRINT ''