I need to check if the datatable has both start and end date is same if yes need to remove the row
For example:
My input
No. Start Date. End Date. Value
01/01/2023. 01/01/2023. 234
12/31/2022. 12/31/2022. 123
01/02/2024. 12/31/2024. 133
My output should be
No. Start Date. End Date. Value
01/02/2024. 12/31/2024. 133
Since first two row has same start and end date.so it should be removed
rlgandu
(Rajyalakshmi Gandu)
February 14, 2024, 8:15am
2
@sruthesanju
dt = dt.AsEnumerable().Where(Function(row) row.Field(Of DateTime)("StartDate") <> row.Field(Of DateTime)("EndDate")).CopyToDataTable()
Note: In my case row.Field(Of DateTime)(“StartDate”) is in datetime .In your excel it may be string please change the datatype as your requirement
Input:
OutPut
mlellison
(Max Ellison)
February 14, 2024, 8:16am
3
Hi @sruthesanju
Try below LINQ
Use assign activity
datatable variable = (From r In dt Where Not r(“StartDate”).ToString.equals(r(“EndDate”).ToString) Select r).CopyToDataTable
Parvathy
(PS Parvathy)
February 14, 2024, 8:32am
4
Hi @sruthesanju
→ Build Data Table
Output-> dt_Input
→ Use the below syntax in Assign:
dt_Input = dt_Input.AsEnumerable().Where(Function(row) row.Field(Of DateTime)("Start Date") <> row.Field(Of DateTime)("End Date")).CopyToDataTable()
→ Write Range Workbook
If your column datatype is System.String then you can use below syntax:
dt_Input = dt_Input.AsEnumerable().Where(Function(row) row.Field(Of String)("Start Date") <> row.Field(Of String)("End Date")).CopyToDataTable()
Hope it helps!!
Getting field is not member of Char
Parvathy
(PS Parvathy)
February 14, 2024, 9:52am
6
Hi @sruthesanju
Can you share your workflow?
or try this:
dt_Input = dt_Input.AsEnumerable().Where(Function(row) row.Field(Of String)("Start Date").ToString() <> row.Field(Of String)("End Date").ToString()).CopyToDataTable()
Regards
rlgandu
(Rajyalakshmi Gandu)
February 14, 2024, 10:06am
7
@sruthesanju
If yoy got any error please make a screenshot of it.
dt = dt.AsEnumerable().Where(Function(row) row.Field(Of DateTime)("StartDate") <> row.Field(Of DateTime)("EndDate")).CopyToDataTable()
In read range workbook please enable preserve format to true
system
(system)
Closed
February 17, 2024, 10:07am
9
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.