Did u tried the way as i suggested. I hope that even the dates in excel is in different format, but printed in uipath by default without any specification in format is always as MM/dd/yyyy (if u used ToShortDateString extension too )
Hello @prasath17 ,
Hope you are doing good.
I was off for 2 weeks due to some other priority tasks.
I got the data cleansed from the user and the linq works as expected, however if it does find any rows which are not greater than the current date, then it throws an error "Assign: The source contains no DataRows." how do I resolve this.
I need a support on another topic where in column “A” if the value is “T9” then my value in column “B” should be “I love UIPATH” using LINQ only since I don’t want to use for each because my file contains more than 20000 rows.
for your first question, how u need to filter the dates by current date?
Hello @NIVED_NAMBIAR ,
It should handle the null case, when there are no rows which is not greater that current date then , it should not do anything and allow me to continue with my workflow.
As suggested by @prasath17
(from r in dt1.AsEnumerable where datetime.Parse(r(2).tostring) > now select r).CopyToDataTable
Try this way around
use if condition with condition as
if this condition is True
use assign activity to get filtered rows
dt2= dt1.AsEnumerable().Where(Function(row) CDate(row(columnname)).toString>Now.ToString).CopyToDataTable
if the condition is false:
then do accordingly in else section.
@NIVED_NAMBIAR … Date values cannot be converted to string while comparison. It will not yield the correct result.
Best practice it to use cdate(“String Date value”).date and now.date…for comparison…
I was also thinking same, but when i saw one post regarding this some months back where dates are compared by string, it is working fine as well
did u trued that way?
Dear @prasath17 ,
An example would be much better for a thick skull like me.
@NIVED_NAMBIAR - This is similar to comparing a INT value as string…
Update: Incorrect comparison results while comparing as string…
Dear @NIVED_NAMBIAR ,
I checked your suggestion, it is always giving false although there were records which are existing with dates greater than current date.
@manjesh_kumar - Please try the .date method.
I changed it as per your suggestion
dt1.AsEnumerable().Where(Function(row) CDate(row(“Grn Date”)).Date.Equals(now.Date)).Count<>0
however it still returns “false” though there were 2 records which were greater than current date.
But you are checking for “equals” not “>” that’s why you are not getting the correct result. Change the comparison to >.
@manjesh_kumar - Please look closely…
CDate(row(“Grn Date”)).Date. Equals (now.Date))
In the above code, you are checking the Grn Date is equals to Now.date…i believe none of the values in the sheet has the 08/20 date so it is returning the count to 0.
CDate(row(“Grn Date”)).Date > now.Date)
Note: CDate and Datetime.parse will work based on the local system settings, i.e. my local settings MM/dd/yyyy so if use cdate with dd/MM/yyyy format it will thrown an error.
You get it??
Suggestion: Before using LINQ please try the simple for each row and use write Line to print the date values and then based on that use If condition to check you are getting the right results. Once you successfully done this, you can apply the same logic in LINQ query. This way, you will learn how to play with datetime format and datetime parsing etc etc…
If I were you, my first priority would be to use the incoming data and ensure that I clean or transform the column which I am interested in and save as a new DataTable (
This ensures that you have one uniform format of input data within UiPath, which does not affect your raw data in excel.
And as @prasath17 said take a sample of your transformed table and use simple for each and DataTable activities. It will not perform well for over 5000 rows when compared to linq. You can do this by slicing the Transformed DataTable
SampleTransformedTable= RawInputTable.Clone SampleTransformedTable=TransformedTable.AsEnumerable().Take(50).CopyToDataTable()
SampleTransformedTable= RawInputTable.Clone → This extracts Header Type and Headers names and creates a DataTable named
SampleTransformedTable=TransformedTable.AsEnumerable().Take(50).CopyToDataTable() → This takes top 50 rows from the
TransformedTable and copies them to
That is my two cents
Dear @prasath17 ,
Yes I made a terrible mistake, my bad I am absolutely sorry for that and being patient with me.
I corrected the code and now it is running as expected.
This should be TransformedTable.clone right? Please correct me if I am wrong @jeevith …
Yes the idea was to use the same column names as RawInputTable, if the TransformedTable has additional columns after transformation then it is best to use TransformedTable.Clone(). So both should work fine if the column names and types are different.
Good spotting: TransformedTable.Clone() would be the safer choice.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.