Order By the Date

How to order by a column of Date in datatable of this format - “MMM-yy” and then copy to datatable???..
Can anyone reply me as soon as possible???..

1 Like

Try like this,

yourDatatable.Select("",“ColumnName DESC”).CopyToDataTable

Thanks!

3 Likes

Hi
The expression would be like this
dt = dt.Asenumerable().OrderBy(Function (a) Datetime.Parseexact(a.Field(of String)(“yourcolumnname”).ToString,“MMM-yy”,system.globalization.CultureInfo.InvariantCulture)).CopyToDatatable()

but ensure that the column date format is of this format “MMM-yy”
else we need to mention the format in the above expression as per we have in the excel column

Cheers @Manish540

3 Likes

Were we able to get this
Kindly let know for any queries or clarification
Cheers @Manish540

I want to get date in ascending order by year wise…

This Query is not working, its showing System.DateTime conversion to System.String is not possible…

This query orders the month in the ascending order not by the year wise.
I want the ascending order of date in year wise??..

Hi @Manish540,

Try this

DT1.AsEnumerable().OrderBy(Function(p) CDate(p("DateColumnName"))).CopyToDataTable
1 Like

Its not working for me…
I have date format as “yy-MMM” this form…