I have data table as below.
But I want filter column APADT by use filter dataTable > 25650101
But after filter —> It show blank data.
Please guide me for solve it.
I have data table as below.
But I want filter column APADT by use filter dataTable > 25650101
But after filter —> It show blank data.
Please guide me for solve it.
Hi @fairymemay
If it is an date, then you can use the follow snippet of code →
Dt.AsEnumerable().Where(Function(w) DateTime.ParseExact(w("APAPDT").ToString.Trim,"yyyyMMdd",Nothing) > [DateToCompareWith] ).CopyToDataTable()
But if its a integer, then you can use the following snippet of code →
Dt.AsEnumerable().Where(Function(w) CInt(w("APAPDT")) > [ValueToCompareWith]).CopyToDataTable
Kind Regards,
Ashwin A.K
@fairymemay You can convert string data to int using following command.
out_intvalue = Cint(in_str)
The output will in integer data type.
Here column name should be APAPDT but not APADT. you can try below Linq query.
dtOutput = dtInput.AsEnumerable.Where(Function(row) Cint(row("APAPDT").ToString) > 25650101).CopyToDataTable
refer to my sequence
test.xaml (15.6 KB)
you can create a new datatable and add integer columns then clone the old datatable over
Example datatable (dt)
steps
initialize new datatable dtNew
loop over dt.Columns, for each column add new column (type integer) to dtNew
loop over dt rows, for each row create add the corresponding values (converted to integer) to a new row in dtNew
now dtNew is the same as dt, but converted to integer
@ashwin.ashok If I have file config for keep date for filter as below.
If filter column APADT (for filter from column Start_APAPDT and End_APAPDT) and filter APDODT (for filter Start_APDODT and End_APDODT)
How to edit your code?
Dt.AsEnumerable().Where(Function(w) CInt(w("APAPDT")) > [ValueToCompareWith]).CopyToDataTable
Please guide me about it.