Click here to Skip to main content
14,390,428 members
Rate this:
Please Sign up or sign in to vote.
i tried below code but i want to display data from monday to saturday means if user login on wednesday it show data from monday to saturday only not wednesday to tuesday

OR (@Range='This Week' AND CAST(S.ScheduleDateTime AS DATE) >= DATEADD(week, DATEDIFF(day, 0, getdate())/7, 0)  AND CAST(S.ScheduleDateTime AS DATE) <= DATEADD(week, DATEDIFF(day, 0, getdate())/7, 5))
Posted
Updated 5-May-14 12:33pm
v3
Comments
Peter Leow 5-May-14 9:52am
   
what happens if the user logs in on:<br><br>
1. Monday ??<br><br>
2. Saturday ??<br><br>
3. Sunday ??<br>
3. if Wednesday, is there data available from Wednesday to coming Saturday?

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

SELECT DATEADD(ww, DATEDIFF(ww,0,GETDATE()), 0) AS Monday, DATEADD(ww, DATEDIFF(ww,0,GETDATE()), 5) as Saturday
   
Comments
Maciej Los 6-May-14 5:49am
   
Excellent!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100