?
Solved

create SQL Calendar

Posted on 2008-10-21
3
Medium Priority
?
218 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
adlink_la earned 1500 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 Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

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