[Resolved] MSSQL Sorting Woes

SpaceshipSpaceship
Watch

Unknown

Established Member
Impact
3
MSSQL Sorting Woes

I'm trying to retrive the top 5 rows of a table based on the column "DateAdded" whose value is supplied via an ASP.NET script when a new row is inserted into the table. Currently when I run the SQL statment all works well except for the fact that it assumes that one digit days are newer than 2 digit days, so:

It will show 11/5/2008 before it shows 11/12/2008
11/1/2008 11/20/2008

here is my current statment:
Code:
SELECT     TOP (5) PlaceId, UserId, PlaceName, PlaceLocation, PlacedDateAdded
FROM         places_table
ORDER BY PlacedDateAddedDESC
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
this may not be it but in the statement you have:-

PlacedDateAddedDESC

try putting a space before DESC

Also are you receiving any error messages?
 
1
•••
Figured it out. I guess I never set the column type as SmallDateTime, instead it was NVarChar :P thanks
 
0
•••
Dynadot — .com TransferDynadot — .com Transfer
Appraise.net

We're social

Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomainEasy — Zero Commission
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back