Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
skillile
Posting Yak Master
208 Posts |
Posted - 2002-09-07 : 14:37:11
|
| I want to grab all dates for the week after the user submits a date. So If user submits tue, I want sun, mon, tue, wed thr, fri, sat in return. Here is what I have but I think there must be a better way.DECLARE @ddate smalldatetime, @sdate smalldatetime, @x intSET @ddate='09-11-2002 8:00'SET @x = datepart(dw, @ddate)SET @sdate = dateadd(dd, (-@x+1), @ddate)WHILE datepart(dw, @sdate) < 7BEGIN SELECT @sdate SET @sdate = dateadd(dd, 1, @sdate)END-- I would then get the last day by adding 1Thanksslow down to move faster... |
|
|
robvolk
Most Valuable Yak
15732 Posts |
|
|
|
|
|