Solved

create SQL Calendar

Posted on 2008-10-21
3
213 Views
Last Modified: 2011-10-19
Hi

I need some help.

I am using SQL 2005, and I have a calendar created, attach is an example of how my calendar looks.

What I would like to go is create a script that would update the table BTItem that has a field name 'DATE'
which would have a numeric value e.g.  1 = Sunday,  2 = Monday....etc...so the script would add 1 to the date field.

But here is the catch, I only want the script to run on working days.
Weekends and holidays I DO NOT want it to update the table BTItem.

What is the SQL code for this ???

I am at a lost.
Time.xls
0
Comment
Question by:jamesb_007
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
adlink_la earned 500 total points
ID: 22767657
How about having your script query your calendar table for DayNoWeek where DateGregorian = CONVERT(VARCHAR, GETDATE(), 101).  Then only let it run if DayNoWeek is between 2 and 6.
0
 
LVL 5

Expert Comment

by:adlink_la
ID: 22767720
As for the holidays, you will need to add a column to your calendar table to put them in or create another table that you can join to, to get them.  A seperate table would probably be easier to manage.
0
 

Author Comment

by:jamesb_007
ID: 22768839
Thanks Bro !!!


I understand......working good so far.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need help creating a stored procedure 4 60
Isolation level in SQL server 3 50
Following an example - removing duplicate strings 4 55
Need help debbuging stored procedure 21 41
There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question