Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Query Sensitive To Day Of Week

Posted on 2011-09-19
2
Medium Priority
?
355 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:Phil Chapman
2 Comments
 
LVL 23

Accepted Solution

by:
wdosanjos earned 2000 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:Phil Chapman
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

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

810 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