SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Compute Holiday Day of the Month for any Year


Compute Holiday Day of the Month for any Year

Author
Message
eric.notheisen
eric.notheisen
Mr or Mrs. 500
Mr or Mrs. 500 (599 reputation)Mr or Mrs. 500 (599 reputation)Mr or Mrs. 500 (599 reputation)Mr or Mrs. 500 (599 reputation)Mr or Mrs. 500 (599 reputation)Mr or Mrs. 500 (599 reputation)Mr or Mrs. 500 (599 reputation)Mr or Mrs. 500 (599 reputation)

Group: General Forum Members
Points: 599 Visits: 307
Comments posted to this topic are about the item Compute Holiday Day of the Month for any Year
Lee Linares
Lee Linares
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1116 Visits: 1508
Eric,
Thanks for taking the time to share this code with us. Very handy. I am confused though with the New Years Day computations. You have these 2 lines:
when 1 then DateAdd(d, 1,@sYear+'-'+'01'+'-'+'01')
when 7 then DateAdd(d, 3,@sYear+'-'+'01'+'-'+'01')

So if New Years Day falls on a Sunday (as in 2017) you add 1 day and it is celebrated on Monday. But if it falls on a Saturday (as in 2011) you add 3 days and it is celebrated on Tuesday. Wouldn't you just add 2 so it is celebrated on Monday?

Thanks again.

Lee
Lee Linares
Lee Linares
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1116 Visits: 1508
Eric,

Sorry, but one other thing. In your example output for 2015 several of the Monday holidays are showing 5 for the DayOfWeek value and Presidents Day is showing 1.

Lee
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search