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
 Order weeks by current week

Author  Topic 

rookie_sql
Constraint Violating Yak Guru

443 Posts

Posted - 2011-01-24 : 15:47:57
Hi is it possible or order weeks so that the currect week is at the top of the ordering. Given that you have all 53 weeks in a table.

example this is week 5 so my ordering would look like

5
4
3
2
1
53
52
51
50

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-01-24 : 15:51:46
Do you have a column that reflects the date? If so, then sort it by that. Otherwise, you can use the DATEPART function in the ORDER BY, but this is definitely not recommended for performance reasons.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

rookie_sql
Constraint Violating Yak Guru

443 Posts

Posted - 2011-01-24 : 15:56:23
Hi I got it sorted. I was doing this in SSRS so i created a new dataset called current week and that gets the week from datapart function so i used that in the default value and still have my list of weeks in the drop down also.
Go to Top of Page
   

- Advertisement -