Now I use activity sort range column Planned start but output wrong as below.
Please guide me for solve it.
Thank you.
Now I use activity sort range column Planned start but output wrong as below.
Please guide me for solve it.
Thank you.
Looks like the column is recognized as text or general…if it is recognized as date only then it wpuld sort properly…
One way would be to use format cells activity first and chnge the type of column to date and then use sort
Cheers
@Anil_G Yes this column type = general.
How to set format for sort data ?
@Anil_G How to set source?
Now I use inputDT.Sheet(“input”).
How to set column that I want set type?
@Anil_G after set format cell, format call wrong as below.
Actual format that true should 10/04/2024 10:33
Please guide me for solve it.
Thank you.
Can you try directly selecting date and check please instead of custom…
Also is it possible to provide a sample file here
Cheers
Hey @Stef_99
No need to use any sorting activity for this just take a assign activity:
dt_Input = dt_Input.AsEnumerable().OrderBy(Function(x) DateTime.ParseExact(x("Planned Start").ToString,"dd-MM-yyyy HH:mm",System.Globalization.CultureInfo.InvariantCulture)).CopyToDataTable
Screenshot for you reference:
As you can see in immediate panel date are sorted in Ascending Order.
Regards,
Ajay Mishra
While reading file you have to tick Preserve format in the property of Read Range!
Attaching .xaml for your reference.
DateSortingSequence.xaml (9.3 KB)
Happy Automation!
Regards,
Ajay Mishra
RPA Developer
@Ajay_Mishra I will try and update to you again.
@Ajay_Mishra it error as below.
I can see in your output panel date format is change to d/M/yyyy HH:mm
dt_Input = dt_Input.AsEnumerable().OrderBy(Function(x) DateTime.ParseExact(x("Planned Start").ToString,"d/M/yyyy HH:mm",System.Globalization.CultureInfo.InvariantCulture)).CopyToDataTable
Try above query, I have just change in input date format!
If this gives error then try below mentioned query:
dt_Input = dt_Input.AsEnumerable().OrderBy(Function(x) DateTime.ParseExact(x("Planned Start").ToString,"M/d/yyyy HH:mm",System.Globalization.CultureInfo.InvariantCulture)).CopyToDataTable
Hope above query will resolve your issue, or after the error in immediate panel put dt_Input(11)("Planned Start")
and dt_Input(12)("Planned Start")
just send me a screenshot so that I will get an idea about your date format!
Regards,
Ajay Mishra
Hey @Stef_99 Although you got the solution but, If your input date format is changing or is in multiple formats then you can also use below mentioned LinQ.
dt_Input = dt_Input.AsEnumerable().OrderBy(Function(x) DateTime.ParseExact(x("Planned Start").ToString,{"dd-MM-yyyy HH:mm","dd/MM/yyyy HH:mm","d/M/yyyy HH:mm","M/d/yyyy HH:mm","MM-dd-yyyy HH:mm","MM/dd/yyyy HH:mm"},System.Globalization.CultureInfo.InvariantCulture,DateTimeStyles.None)).CopyToDataTable
Happy Automation!
Regards,
Ajay Mishra
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.