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 |
gvmk27
Starting Member
44 Posts |
Posted - 2015-01-16 : 09:47:30
|
I have below SQL, which should be order by posteddate ASCSELECT AnnouncementID,[Subject],[Description], CONVERT(nvarchar(10),PostedDate,101) AS PostedDate, CONVERT(nvarchar(10),ExpiredDate,101) AS ExpiredDate, CountryID,CreatedBy, CreatedDate, ModifiedBy, ModifiedDate FROM Announcements a WHERE isActive = 1 AND CountryID = 2 AND (GETDATE()>= PostedDate) AND (GETDATE()<= ExpiredDate) ORDER BY PostedDate ASC but result is displaying as below, PostedDate datatype is datetime01/01/201501/02/201512/28/201412/31/2014expected result is 01/02/201501/01/201512/31/201412/28/2014 |
|
mhorseman
Starting Member
44 Posts |
Posted - 2015-01-16 : 10:42:39
|
To get your expected result (most recent first), then you needORDER BY PostedDate DESCHowever based upon the actual result, I suspect that PostedDate is actually a character datatype.Mark |
|
|
|
|
|
|
|