Solved

create SQL Calendar

Posted on 2008-10-21
3
211 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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Suggested Solutions

In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now