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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-02-21 : 12:14:44
|
Stuart writes "I have an ASP application retrieving SQL Server 7 data through OLEDB using standard SQL statements on an NT 4 Server. The application takes two arguments; a column name (colname) and a sort direction (sortdir).
The results of the SQL Statement are displayed in a table on the webpage that will also allow you to select a column header which then resorts the table data, dependent on the column name you selected. By default, the direction is ASC. If you select the column that is currently sorted, then the sort direction is switched.
Anyway, the SQL Statement is long, but I'll simplify it for my question:
SELECT id, CONVERT(varchar(10), mydate, 101) finaldate, account_name from my table ORDER BY finaldate ASC
The reason I chose to convert is because the data is returned as DATETIME and I only want the data displayed as: MM/DD/YYYY. This may be where my error is. Now, through my application, I've made the last two keywords dynamic: finaldate and ASC -- these will differ depending on what's selected on the page.
Everything works wonderfully if I sort by any column OTHER than date. If I sort by date, it sort, but by the month only. For example, if I select finaldate to sort by, it displays all the Januarys then Februarys and so on -- but mixes the years. Why? How can I get it to sort chronologically?" |
|
|
|
|
|
|
|