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 8862883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:50:15+00:00 2026-06-14T15:50:15+00:00

I have to collect all the rows in a table where they were inserted

  • 0

I have to collect all the rows in a table where they were inserted on a Monday for the last 3 three months. How would I write the WHERE clause date to get those results?

WHERE Date = (wk, DATEDIFF(wk,0,GETDATE()), 0)

That will select everything from Monday of the current week, but what I am having a problem with is selecting a range of Mondays going back three months.

thanks!

So this is the WHERE clause I ended up with that works well for me….

where Datestamp > dateadd(month, -3, getdate())
AND datepart(weekday, Datestamp) = datepart(weekday, DATEADD(wk, DATEDIFF(wk,0,GETDATE()), 0))

I changed only the part where we enter the day of the week that starts on Monday I added this…

DATEADD(wk, DATEDIFF(wk,0,GETDATE()), 0)
  • 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-06-14T15:50:16+00:00Added an answer on June 14, 2026 at 3:50 pm
    WHERE Date > dateadd(month, -3, getdate())
    AND datepart(weekday, Date) = 1
    

    These are two separate conditions; no need to compress them into one.

    Note: run a test on your machine to see which value you get for datepart(weekday, @AMondayDate). On some systems Monday is 1, on others is 2; it depends on the DATEFIRST configuration.

    Update:

    Thanks to ErikE for the clever trick that overcomes the weekday numbers issue:

    WHERE Date > dateadd(month, -3, getdate())
    AND datepart(weekday, Date) = datepart(weekday, '2012-11-25')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have the following code to collect all the possible combinations. abArray =
I have written a Windows service to collect information from all of our SQL
I have various models of which I would like to keep track and collect
I have a question. How would I build a method (dataCapture()) to collect the
I have a database table with 10,000,000+ rows which I process to create a
I have a solution folder in which I have collect all the .dll's and
What I wanted to have is to collect all the results in an ArrayList
I have a Decorator Control class which I want to collect all the validation
I want to write an user defined error collection class which should collect all
my goal is to write a stored proc that can collect all field values

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.