I have situation where I download data from SAP and in the data table I do a filter on the date for a certain condition there is no output in the new data table.
If “Grn Date” is a datetime (which is what you want) then you don’t do .ToString(“MM/dd/yyyy”) in the Value box. Just do getLocalDateTime (which is a datetime, not string, value). You have to compare like datatypes - so both the Column and the Value should be datetimes.
Note: After reading your sheet, first use a for each and print the date column value to see how it is printing first. Based on that you have to decide your code for Datetime.parseexact, it will always easy if you do this way.
Thank you for this hint, however this is adding burden to my program which has increased by 7 minutes. The reason is that it has to loop through 18000 records, and doesn’t get better as the year progresses.
Is there an alternate method which can fulfil this requirement and reduce the time.
@manjesh_kumar - you didn’t use the LINQ query screenshot which I provided ? The for each loop thing is just to show you how the date format works for the data you shared.
Hello @manjesh_kumar
you can try this—
ThirdPartDT.AsEnumerable.Where(function(r) Convert.ToDateTime(r(“Grn Date”).ToString)>GetLocalDateTime).ToArray.CopyToDataTable
@manjesh_kumar - If this is your orignal file, I see some blank rows here…
If you have blank rows, none of of code will work. You have to sort the blank rows first by keeping only the rows with values and then apply LINQ query…
Will send you the code shortly…
Note: you never mentioned that you column has blank values…
Hi @manjesh_kumar
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 )
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.
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.