Dear Team
I have a excel file wich contain data from first date of the year to the current date,
I would like to sort it from Current date to oldest date, Adding a excel file.
Autoreport Status 2024.xlsx (11.2 KB)
Thanks,
Amol Golhar
Dear Team
I have a excel file wich contain data from first date of the year to the current date,
I would like to sort it from Current date to oldest date, Adding a excel file.
Autoreport Status 2024.xlsx (11.2 KB)
Thanks,
Amol Golhar
Hi @Amol_Golhar
Check out the below zip file. I have sorted based on EmailTime VRL column. Hope this meets your requirement.
sortedDt = (From row In dt_Input.AsEnumerable()
Order By DateTime.Parse(row("EmailTime VRL").ToString()) Descending
Select row).CopyToDataTable()
sortedDt is of DataType System.Data.DataTable
Excel Forum.zip (164.4 KB)
Hope it helps!!
Hey @Amol_Golhar
Depends on which column you want to sort, you can use this:
sortedDt = dt.AsEnumerable().OrderByDescending(Function(row) DateTime.ParseExact(row("YourDateColumnName").ToString, "YourDateFormat", System.Globalization.CultureInfo.InvariantCulture)).CopyToDataTable()
eg.
sortedDt = dt.AsEnumerable().OrderByDescending(Function(row) DateTime.ParseExact(row("EmailTime VRL").ToString, "dd-MMM-yyyy HH:mm", System.Globalization.CultureInfo.InvariantCulture)).CopyToDataTable()
Dear Parvathy,
I tried the same work flow on my machine, not working, Is it working on your machine.
I have checked attched excel file by you, it is also not sorted.
FYI, Requirement is we want latest data on top from 10-Feb-2024 to 01-Jan-2024.
Please confirm.
Thanks,
Amol Golhar
Hi @Amol_Golhar
FYI, Output sheet is the expected output. Please check that. Please do mention which is the column you want to sort.
Regards
Date Formats visually offered in Excel are not mandatory the same within the resulting DataTable, when we read in the data e.g. with read range.
In the below firstAid a few analyis steps are described
Once these details are cleared, then maybe a few modifications are done on the above provided suggestions (e.g. format definition, null / empty value handling).
But in general we would sort the data with a LINQ the Order Clause or the ORderByDecending Operator
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.