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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Help with Stored Procedure

Author  Topic 

JJ297
Aged Yak Warrior

940 Posts

Posted - 2010-01-12 : 11:42:33
You guys helped me with this before but my client wants to display the info the opposite way which I have now.

When a user selects a date I would like for six weeks displayed (of data) at all times.

If I select date 11/06/09 the dates displayed (with data) are:

11/06/09
11/13/09
11/20/09
11/27/09
12/04/09
12/11/09

I would like for it to display this way instead
11/06/09
10/30/09
10/23/09
10/16/09
10/09/09

How do I change this where clause I can't figure it out.


@Dist char(3),
@StartDate datetime

Select *

from Totals

where dist = @dist and sort='y' and WKDate >= @StartDate AND WKDate < DATEADD(wk, 6, @StartDate)
order by WKDate

By the way these are Friday's in every month.

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-01-12 : 11:47:48
[code]where dist = @dist and sort='y' and WKDate >= @StartDate AND WKDate < DATEADD(wk, -6, @StartDate)
order by WKDate desc[/code]
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-01-12 : 11:49:36
Oops..other way..

where dist = @dist and sort='y' and WKDate > DATEADD(wk, -6, @StartDate) AND WKDate <=@StartDate
order by WKDate desc
Go to Top of Page

JJ297
Aged Yak Warrior

940 Posts

Posted - 2010-01-12 : 11:55:18
I tried that but I'm not getting any records
Go to Top of Page

JJ297
Aged Yak Warrior

940 Posts

Posted - 2010-01-12 : 11:56:14
Thanks it's working! Did see that post.
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-01-12 : 12:00:44
Np.You're welcome.
Go to Top of Page
   

- Advertisement -