Sort Date Time in String Format with AM PM

Hi, I want to sort my DataTable in Ascending order. “04/21/2020 05:05 AM” this is the format. I used sort datatable but it is only sorting the numbers irrespective of AM PM. Here is how it looks but I want the result in reverse.
Capture

@Nahid_Sultana - welcome to community!

pls try below -

(From row In DTData Order By DateTime.ParseExact(row.Item(“COLUMNNAME”).ToString, “MM/dd/yyyy hh:mm:ss tt”,
System.Globalization.CultureInfo.InvariantCulture) Ascending Select row).CopyToDataTable

1 Like

Hi,
I tried but this error Pops “Assign: String was not recognized as a valid DateTime.”