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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Date sorting

Author  Topic 

SQL360
Starting Member

20 Posts

Posted - 2009-02-17 : 16:28:43
I have a column called date and when I query the date column
for two years, for example startdate, 01/01/2008 to end date, 12/30/2009 it gives me result with year 2009 dates first followed by year 2008 dates.

I need to sort so that it gives me dates for year 2008 first and then dates for year 2009. I am pulling these dates from the table.

Getting Result Desired Result
02/15/2009 01/01/2008
01/01/2008 01/02/2008
01/02/2008
01/01/2009

Thank You
SQL360

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-02-17 : 16:31:07
What is the data type of your column?

Have you tried ORDER BY YourColumn ASC?

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

Subscribe to my blog
Go to Top of Page

SQL360
Starting Member

20 Posts

Posted - 2009-02-17 : 16:33:37
Data Type for the column is datetime and size 8.

SQL360
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-02-17 : 16:51:31
quote:
Originally posted by SQL360

Data Type for the column is datetime and size 8.

SQL360



Datetime doesn't have size 8
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-02-17 : 16:53:05
Did you try ORDER BY ASC?

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

Subscribe to my blog
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-02-17 : 16:57:38
quote:
Originally posted by sodeep

Datetime doesn't have size 8
Not? And SMALLDATETIME doesn't have a size of 4 bytes?



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -