My excel my data is in string format so sorting of ascending to descending order is not working

I want to sort my excel based on H column “Fine Elaborazione” but in H column data is in general format this is why my sorting is not working can you try i am sharing my existing code for sorting

this is invoke code

inputDataTable.DefaultView.Sort=(“Nr. Fattura ASC, Fine Elaborazione DESC”)
finalDT = inputDataTable.DefaultView.ToTable

my excel data is not in date format so sorting is not happing perfectly.

I want to sort my excel based on H column “Fine Elaborazione” but in H column data is in general format this is why my sorting is not working can you try i am sharing my existing code for sorting

this is invoke code

inputDataTable.DefaultView.Sort=(“Nr. Fattura ASC, Fine Elaborazione DESC”)
finalDT = inputDataTable.DefaultView.ToTable

so this is the actual format
Fine Elaborazione
27-06-2023 22:31:36.373
24-05-2023 18:02:34.967
24-05-2023 12:37:06.797
14-10-2023 04:11:00.340
08-06-2023 12:45:18.667\

when i am sorting excel from desc to asc

Fine Elaborazione
27-06-2023 22:31:36.373
24-05-2023 18:02:34.967
24-05-2023 12:37:06.797
14-10-2023 04:11:00.340
08-06-2023 12:45:18.667

sorting is not working well excel is taking date as sorting but i need extact data sorting

this is how ouput should be
14-10-2023 04:11:00.340
27-06-2023 22:31:36.373
08-06-2023 12:45:18.667
24-05-2023 18:02:34.967
24-05-2023 12:37:06.797

can you try in my excel H column is showing general type so issue
thanks in advance

grafik

Give a try at

Assign Activity:
dtSorted =

(From d in inputDataTable.AsEnumerable
Let ds = d("Fine Elaborazione").toString.Trim
Let dp = DateTime.ParseExact(ds,"dd-MM-yyyy HH:mm:ss.fff", System.Globalization.CultureInfo.InvariantCulture)
Order by dp DESCENDING
Select r = d).CopyToDataTable

For parsing issue analysis have a look here:
:ambulance: :sos: [FirstAid] Datatable: Debug & Analysis invalid DateTime Strings / String to DateTime Parsing Issues - News / Tutorials - UiPath Community Forum

i am getting errors like brackets can you give me code i will copy it

we fixed it above

and added )

Thanks bro worked for me

Perfect, so the topic can be closed by
Forum FAQ - How to mark a post as a solution - News / Tutorials - UiPath Community Forum

in this excel i have to delete last 10 days data based on checking M column InvDT
we have to delete the last 10 days rows of data

in my excel M column i have thi data

InvDT
04/30/2024
04/30/2024
04/29/2024
04/29/2024
04/28/2024
04/28/2024
03/13/2024
04/09/2024
04/11/2024

here my excel problem is this dates are coming in string format which conatins spaces in front and back of dates its taking like string i have tried filter data table but idid not work
check my execel attachment
can you try by linq and share me soultion in detail

Thanks in Advance
Fabbucket
SQL.xls (1.2 KB)

just open a new topic for your new case. We prefer 1 Topic = 1 case as other researchers can faster find solutions for their similar use cases.

For a little preview

we could trim it with the string trim method

I have tried trim Spaces are deleting but converting string to data is not happening can you try using linq it would help me
Thanks in advance

as mentioned we will it pick it up from the new topic, once you have created

Yes i have created new topic

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