![]() |
| |||||||
![]() |
| | LinkBack (1) | Thread Tools | Display Modes |
| |||
| Hi, I dont want to display the current topic and i want to display the topics starting from 2008 and then going to 2000 or 1999 so i am sorting on topic date but its not working any idea Code: sqlstr="SELECT * FROM Topics WHERE (Topic_Date <> (SELECT TOP 1 Topic_Date FROM Topics WHERE Topic_Date <= getDate() ORDER BY Topic_Date desc)) order by Topic_Date desc" todd |
| Sponsored Links |
| ||||
| I agree -- however even a character 4-digit year should sort correctly. I wonder about the condition Topic_Date <= getDate(), which compares a VARCHAR with a DATE value. I'm surprised the query even parses. Beyond that, since date/times are nothing more than integers internally, I'm thinking that this compare isn't doing what you think it is. Even if the analyzer figure it out, it would be something like saying '2008' <= '04/15/2008 12:00:00 AM' |
| |||
| Hi, this works out Code: sqlstr="SELECT * FROM Topics WHERE (Convert(datetime,Hot_Topic_Date) <> (SELECT TOP 1 Convert(datetime,Hot_Topic_Date) FROM Topics WHERE Convert(datetime,Hot_Topic_Date) <= getDate() ORDER BY Convert(datetime,Hot_Topic_Date) desc)) order by Convert(datetime,Hot_Topic_Date) desc" |
| ||||
| I would seriously consider changing your data type to DateTime It would avoid needless conversions ![]()
__________________ ................... ASCII and ye shall receive .................. Knowledge is the only resource on earth that multiplies when shared If you found a post helpful, please click the 'Thanks' button in the lower right-hand corner of the post. |
![]() |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
LinkBacks (?)
LinkBack to this Thread: http://www.developerbarn.com/sql-development/133-ordering-problem.html | ||||
| Posted By | For | Type | Date | |
| DeveloperBarn Forums - ASP Help, ASP.Net Help, PHP Help, SQL Help, Tutorials, Windows Help | This thread | Refback | 04-26-2008 09:36 AM | |
| Sponsored Links |
| ASP.NET Resource Index a directory of ASP.NET tutorials, applications, scripts, assemblies and articles for the novice to professional developer. Free Web Directory Including Chats and Forums Resources, Offer automatic, instant and free directory submissions. | URLZ Web Directory URLZ Web Directory Free Web Directory - Add Your Link The Little Web Directory | Free Web Directory Pegasus free web directory is a free directory organised by categories. |