I have a data table in the below format:
I need to delete all rows where Operator_ID(Cancellation) is blank. I need to delete all rows where TRANSACTION_DATE is not yesterday.
Kindly suggest how to do this using LINQ.
Use filter data table activity
Thanks but Date is in time stamp format :
I will keep 3/15/2021 6:58 and delete the rest
This is not working in case of dates.
I am getting output dataTable as blank.
First check if column TRANSACTION_DATE in your dt has DateTime value type. If not u can parse it like here:
i need to convert a column of string(such as “25/08/20”,“15/08/20”,“17/07/20”) from a datatable to datetime formats without loop inside datatable.
i have a problem with this assign:
(From row In Compressed2 let dt= convert.ToDateTime(DateTime.ParseExact(row.Item(“Column2”).ToString,“dd/MM/yy”,Globalization.CultureInfo.InvariantCulture)) Select row).CopyToDataTable
nothing happens with this expression… Help Me Please!!
Next use filter with remove for Operator_ID(Cancellation) is empty.
Use another filter activity with keep for:
TRANSACTION_DATE >= Today.AddDays(-1) AND
TRANSACTION_DATE < Today
Replace cancel_date filer with >= Now
or cancel_date <= now.adddays(-2)
we can use a LINQ statement. It allows us a good control on datatype and conversion handlings
Use an assign activity
Leftside: dtFiltered - Datatype: datatable
(From d In YourDataTableVar.AsEnumerable
Where Not (IsNothing( d("Operator_ID(Cancellation)")) OrElse String.IsNullOrEmpty(d("Operator_ID(Cancellation)").toString.Trim))
Where Not CDate(d("TRANSACTION_DATE").toString.Trim).Date <> now.AddDays(-1).Date
For a defensive handling of empty result we can apply following pattern:
I assume I can change that cdate to datetime.parseexact to show the pattern of the string if I know it? I would use that in my automation
yes. This can be done and it gives a more deep level of control we often do this as well
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.