Date between Monday and previous day of week in TSQL

I'm trying to pull all records between Monday and the day before.

For instance, on Thursday, I need the date range of Monday through Wednesday.

I've got a script that uses the following code:

 
SELECT * from dbo.events
WHERE dbo.events.eventdate BETWEEN DATEADD(wk,DATEDIFF(wk,7,getdate()),6) and getdate() 

Open in new window


This gives the range a start day of Sunday. How should I modify it to treat Monday as the start of the week?

Thanks in advance.
bildozerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott PletcherSenior DBACommented:
Avoid WEEK just in case the DATEFIRST setting affects it (I'm not sure).  Below code works accurately with any DATEFIRST and/or language settings.

For now, returns the same day if it's already a Monday, wasn't sure what you needed in that case.

SELECT e.*
FROM dbo.events e
WHERE e.eventdate >= DATEADD(DAY, -DATEDIFF(DAY, 0, GETDATE()) % 7, GETDATE()) AND
    e.eventdate < CAST(GETDATE() AS date)
1
Robin RobertDatabase SpecialistCommented:
Set it in a query
SET DATEFIRST 1;
Value First day of the week is 1 Monday 2 Tuesday 3 Wednesday 4 Thursday 5 Friday 6 Saturday 7 (default, U.S. English) Sunday
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.