Solved

Query Sensitive To Day Of Week

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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

740 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