Hi Guys,
I have a column date in my DataTable and i want to sort the date by Month.
How can i do that?
Thanks and Happy Automations,
Hi Guys,
I have a column date in my DataTable and i want to sort the date by Month.
How can i do that?
Thanks and Happy Automations,
HI @jmeier
Try this below expression
(From r In DT Order By DateTime.ParseExact(r.Item(“YourColumnName”).ToString, “MM/dd/yyyy”, System.Globalization.CultureInfo.InvariantCulture) Descending Select r).CopyToDataTable
MM/dd/yyyy → Date format of the column date
Regards
Gokul
dt.AsEnumerable.OrderBy(Function(r) Convert.ToDateTime(r(“Date_column”))).CopyToDataTable
Hi Gokul001,
I want to sort only by month.
For example i have this dates (19/02/1993;18/02/1991;17/01/2001). I want this to be sorted like:
17/01/2001;
18/02/1991;
19/02/1993.
Fine
Hope the below steps would help you resolve this
As you want to sort only on month basis this needs some tweak before sorting them out
Hope you have a datatable named dt
Use a add datacolumn activity and mention column name temp_col and mention datatable as dt so that it gets added at last to the datatable and mention type argument as int32
Now use a FOR EACH ROW activity and mention dt as input
Inside the loop use a assign activity like this
row(“temp_col”) = Convert.ToInt32(Split(row(“Date_columnname”).ToString, “/“)(1).ToString.Trim)
Now outside this loop use a SORT DATATABLE activity and pass dt as input and mention the column name as temp_col and mention ascending or descending
Now you will get the datatable sortrd based on this temp col and you can see the date column arranged in the order you want
Let’s delete the temp column now with remove datacolumn activity so that you get the chat output you want
Cheers @jmeier
Did that work in your scenario @jmeier
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.