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 by date - year not month

Author  Topic 

hardwood
Starting Member

19 Posts

Posted - 2010-07-15 : 12:37:43
Hi,

I have a query that has an Order By Date clause (Date being one of my columns). It works well when I run it, but it orders by month and not by month/year.

For example, this is what my date column looks like:

01/2004
01/2005
01/2006
02/2004
02/2005
...

and I want it to be in order:
01/2004
02/2004
01/2005
02/2005
01/2006
02/2006

meef
Posting Yak Master

113 Posts

Posted - 2010-07-15 : 13:40:52
ORDER BY YEAR(date), MONTH(date) DESC or ASC?

I'm not sure, all I usually need to do is ORDER BY date DESC and it's in year and month/day order.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-07-16 : 11:28:03
What is the datatype of the column?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -