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.
Author |
Topic |
Sun Foster
Aged Yak Warrior
515 Posts |
Posted - 2007-10-26 : 16:34:25
|
I stored date data in varchar type.How to sort them?If I sort desc, '2/15/2007' is before '09/06/2007' which is wrong. |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-10-26 : 16:35:09
|
Convert it to datetime then sort.Or fix your data so that your dates can be sorted via varchar. This would mean using two-digit months and days and four-digit years. mm/dd/yyyyTara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
Kristen
Test
22859 Posts |
Posted - 2007-10-26 : 17:23:13
|
"I stored date data in varchar type"Simple answer is "Don't". There are very few reasons why storing a date in anyothing other than a datetime datatype is useful.Kristen |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-10-29 : 01:27:33
|
quote: Originally posted by Sun Foster I stored date data in varchar type.How to sort them?If I sort desc, '2/15/2007' is before '09/06/2007' which is wrong.
Why did you use varchar datatype to store date values?MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|