shrayud
(Shrayus)
March 16, 2021, 6:31am
1
Hi,
I have a data table in the below format:
SlNo,TRANSACTION_ID,PNR_NO,OPERATOR_ID(Booking),Operator_ID(Cancellation),PG NAME,CLASS,REFUND_AMOUNT,WAITING_AUTO_CANCELLED,TRANSACTION_DATE,TDR_CAN,USER_ID,PRINCIPAL_USER_ID,CANCELLATION_ID
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.
@shrayud
Use filter data table activity
1 Like
shrayud
(Shrayus)
March 16, 2021, 9:14am
3
HI Pravin,
Thanks but Date is in time stamp format :
3/15/2021 6:58
3/14/2021 16:29
3/13/2021 9:16
I will keep 3/15/2021 6:58 and delete the rest
shrayud
(Shrayus)
March 16, 2021, 3:50pm
5
Hi Pravin,
This is not working in case of dates.
I am getting output dataTable as blank.
Yameso
(Jakub Swiderski)
March 16, 2021, 6:36pm
6
First check if column TRANSACTION_DATE in your dt has DateTime value type. If not u can parse it like here:
Hi everyone!
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
@shrayud
Replace cancel_date filer with >= Now
or cancel_date <= now.adddays(-2)
ppr
(Peter Preuss)
March 16, 2021, 9:06pm
8
@shrayud
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
Right side:
(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
Select d).CopyToDatatable
For a defensive handling of empty result we can apply following pattern:
3 Likes
Yameso
(Jakub Swiderski)
March 16, 2021, 10:54pm
9
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
ppr
(Peter Preuss)
March 16, 2021, 11:23pm
10
yes. This can be done and it gives a more deep level of control we often do this as well
1 Like
system
(system)
Closed
April 1, 2021, 3:08pm
12
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.