Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7160729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:26:46+00:00 2026-05-28T13:26:46+00:00

I have a few sql statements where I manually enter the date everyday then

  • 0

I have a few sql statements where I manually enter the date everyday then execute.

I would like to automate the date part. But weekends are giving me trouble. I use excel to run the reports as it is then saved and another member of staff does a mailshot.

This is my test example:

if (datename(dw, getdate()) = 'Friday') BEGIN
select convert(varchar, dateadd(day, 7, DATEADD(dd, 0, DATEDIFF(dd, 0,getdate()))), 103)
 + ',' + convert(varchar, dateadd(day, 9, DATEADD(dd, 0, DATEDIFF(dd, 0,getdate()))), 103) AS [Date] END
ELSE BEGIN select convert(varchar, dateadd(day, 7, DATEADD(dd, 0, DATEDIFF(dd, 0,getdate()))), 103) as [Date] END;

But how would I put this into a sql where statement?

for example

select * from table where (date = )

where Date equals 7 days in advance unless It’s Friday when we have to account for the weekend so we want 7,8 and 9 days in advance?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T13:26:47+00:00Added an answer on May 28, 2026 at 1:26 pm
    select * from table where date = (case
      when datename(dw, getdate()) = 'Friday' then
        convert(varchar, dateadd(day, 7, DATEADD(dd, 0, DATEDIFF(dd, 0,getdate()))), 103)
         + ',' + convert(varchar, dateadd(day, 9, DATEADD(dd, 0, DATEDIFF(dd, 0,getdate()))), 103)
      else
        convert(varchar, dateadd(day, 7, DATEADD(dd, 0, DATEDIFF(dd, 0,getdate()))), 103)
      end)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As part of my integration strategy, I have a few SQL scripts that run
I have a few SQL statements stored in text files. How do I pull
I have a text file with a few SQL statements in it that I
I have few inline sql statements with some arrays and if loops. I want
I have a few SQL Server databases (all in one server), containing their own
I have a few sql scripts that I need to run via SQL*Plus. These
I have a few huge tables on a production SQL 2005 DB that need
We have a few tables with persisted computed columns in SQL Server. Is there
I have a few windwos services. They get xml column from Sql server manipulate
Greetings, I have a few applications/websites running with LINQ to SQL and the other

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.