Data column into Date type and sort from newest to oldest

I’m using this code in assign:

I get an error:

Can anyone please advise?
Thank you


in place of “MM/dd/yyyy”

use this

{"MM/dd/yyyy hh:mm:ss","MM/dd/yyyy","dd/MM/yyyy"}

thanks @Shiva_Nikhil ,
Now I don’t get an error,but the first date I get is 2019…there are more recent dates…
Please advise


can you try this

(From r In dt.AsEnumerable
Order By datetime.ParseExact(r("ColumnName").ToString.Trim,{"MM/dd/yyyy hh:mm:ss","MM/dd/yyyy HH:mm:ss","dd/MM/yyyy"},system.Globalization.CultureInfo.InvariantCulture).Date 
Select r).CopyToDataTable


Can you try this? please.

dt.AsEnumerable.OrderByDescending(Function(r) DateTime.ParseExact(r(“ColumnName”).ToString().Trim,
{“MM/dd/yyyy hh:mm:ss”, “MM/dd/yyyy HH:mm:ss”, “dd/MM/yyyy”},

Thanks @Shiva_Nikhil !
I just changed the last time expression to display the month first

Thanks Mariemily Silva for your help :slight_smile:

Thanks @ppr for your help

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