Avatar of bildozer
bildozer

asked on 

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.
Microsoft SQL Server

Avatar of undefined
Last Comment
Robin Robert
SOLUTION
Avatar of Scott Pletcher
Scott Pletcher
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Robin Robert
Robin Robert

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Microsoft SQL Server
Microsoft SQL Server

Microsoft SQL Server is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.SQL Server is available in multiple versions, typically identified by release year, and versions are subdivided into editions to distinguish between product functionality. Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning.

171K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo