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

  • Home
  • SEARCH
  • 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 3458438
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:58:58+00:00 2026-05-18T09:58:58+00:00

I am stuck and I have not done anything like this before. By providing

  • 0

I am stuck and I have not done anything like this before. By providing todays date e.g 2010-12-04, I should get the following:

startdate = 2010-11-29
enddate = 2010-12-05

Basically I need to filter my query so it gives me data for this ‘week’

any idea on how to start this will be great!

Thanks,

Tarun

  • 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-18T09:58:59+00:00Added an answer on May 18, 2026 at 9:58 am

    Updated: This function is due to Graham at SqlTeam. It returns Monday’s date for any given date; it should cope with any DATEFIRST setting:

    CREATE FUNCTION dbo.WeekCommenceMondayDate(@MidWeekDate DateTime)
    RETURNS DateTime AS
    BEGIN
    DECLARE @WeekCommence DateTime
        SET @WeekCommence = DateAdd(d, -((@@DATEFIRST + DatePart(dw, @MidWeekDate) -2) % 7), @MidWeekDate)
        RETURN @WeekCommence
    END
    
    
    declare @today datetime = '2010-12-04' 
    declare @weekstartdate datetime
    
    set  @weekstartdate = dbo.WeekCommenceMondayDate(@today)
    select @weekstartdate as weekstartdate
    select  DATEADD(DD, 6, @weekstartdate) as weekenddate
    

    For a variety of date functions see here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a noob in jQuery and have stuck at this. I have the following
Hey I have this test back ground worker which seems to get stuck on
I have the following stack trace from valgrind. But it does not give me
I'm totally stuck and have no idea how to go about solving this. Let's
I have been stuck on this for a while now and I cannot seem
I have been stuck on this for days, and was wondering if anyone had
I've done all of this in active record, but it's not going to work
I've looked around on stack overflow for days and have not seen an answer
not sure its a stack overflow question I have a Mac and am hosting
I have a question considering a program that stimulates a stack (not using any

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.