Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

strange problem with grid view sorting 1

Status
Not open for further replies.

jwrz200t

Programmer
Aug 1, 2006
19
US
I am using a grid view which has a column containing dates in ASP.net 2.0. The data is being pulled from a SQL database by which the datasource is connected through OLEDB. The problem that I am running into is that when I click on the date header to sort the field in the gridview, the dates are being sorted in a correct way untill 09/23/2005 but after that the sorting has become erratic that is
09/19/2006
09/16/2006
09/16/2006
09/16/2005
09/16/2005
09/16/2005
09/14/2006
09/14/2006
09/14/2006
09/14/2005
09/13/2006
09/13/2006
09/12/2006
09/12/2006

Can anyone get me out of this????
 
is the date column you are referring to a datetime datatype in the database or is it a character column?
 
That's your problem then, either change the datatype of the column to date time, or convert it to a datetime datatype when you query the table.
 
can u please give me the sql command to covert to datetime while querying???
 
Code:
select 
 case 
    when isdate(datecol) = 1 then convert(datetime, datecol)
 else
     convert(datetime, '01/01/1900')
end  As MyDate
 from yourtable

Jim
 
Which thread of yours was first?

thread855-1281175

or this one?

is it a MySQL Database (your other post) or MS SQL Database?
 
this is my second post and iam using MS sql database
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top