SQLUSA

Microsoft SQL Server 2000

Best Practices

 

How to sort on date column?

 

If you have a date column MMDDYY, it will not sort right in an order by clause.

You have to use the 111, 112 convert option to define the date column as YYYY/MM/DD or YYYY.MM.DD format.

select convert(char(10), getdate(),112)

 

Best in the World in SQL Server Training
 
SQLUSA.com Home Page