Solved

Query Sensitive To Day Of Week

Posted on 2011-09-19
2
292 Views
Last Modified: 2013-11-05
I need to add a second line to the WHERE clause that looks at GetDate() and does not return records if it Friday, Saturday or Sunday

SELECT Account
FROM Accounts
WHERE
DateDiff(day, Accounts.SubmissionDate, getdate()) >= 15 AND
getdate() IS NOT ON Friday, Saturday or Sunday

0
Comment
Question by:PhilChapmanJr
2 Comments
 
LVL 23

Accepted Solution

by:
wdosanjos earned 500 total points
ID: 36562617
Please try:

SELECT Account
FROM Accounts
WHERE
DateDiff(day, Accounts.SubmissionDate, getdate()) >= 15 AND
DATENAME(dw, getdate()) NOT IN  ('Friday', 'Saturday', 'Sunday')
0
 
LVL 2

Author Closing Comment

by:PhilChapmanJr
ID: 36562650
Perfect!!
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Join & Write a Comment

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

760 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

19 Experts available now in Live!

Get 1:1 Help Now