Last post May 04, 2011 10:29 AM by shuffle5
May 04, 2011 08:56 AM|shuffle5|LINK
Im trying to sort my datatable according to one column containing dates. The datatable is filled by a query to my database and because of this the column that needs the sort is of type system.string. Also, I can't sort in my query because i am combining
two datatables together. This makes two different datatables sorted seperatly in one datatable and I dont want that.
Im using this date format in my query:
DAY(DateTravail) & ""/"" & MONTH(DateTravail) & ""/"" & YEAR(DateTravail) AS [Date Travail]
So how can I sort my datatable according to my date column?
May 04, 2011 09:40 AM|smirnov|LINK
if you add a new column with a datetime data type and copy all values from DateTravail and sort it by that new column, would it work?
something like this
DataTable table = new DataTable();
foreach (DataRow r in table.Rows)
r["DateTravail2"] = DateTime.Parse(r["DateTravail"].ToString());
DataView dv = table.DefaultView;
dv.Sort = "DateTravail2";
May 04, 2011 10:29 AM|shuffle5|LINK
Cheers! Thats just what I needed.