Solved

Query Sensitive To Day Of Week

Posted on 2011-09-19
2
313 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

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.
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 different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

813 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

11 Experts available now in Live!

Get 1:1 Help Now