Arrange date in descending order

Is there a way to arrange the date in order?

I tried the below code it isn’t working for date:
dt.DefaultView.Sort = “[Date] DESC”
dt = dt.DefaultView.ToTable

Thank you xoxo

Hi @sangasangasanga,

Use below LINQ code to sort the datatable

(From p In dataTable Order By DateTime.ParseExact(p.Item("Date").ToString, "d MMM yyyy", System.Globalization.CultureInfo.InvariantCulture) Descending Select p).CopyToDataTable

Regards,
Arivu

2 Likes

This will only work if your datatable column is of type datetime or date.

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.