Filter data table with dates

I have the following case:

I have a table with 4 columns where column 4 has date data, I require to filter the data table and keep all rows that are > 2000-02-02

How can I do this?

You can try this:

1 - Add a read range, lets say to dtInput
2 - Add an assign like this:
dtOutput = dtInput.AsEnumerable().Where(Function(row) DateTime.ParseExact(row.Field(Of String)(3), “yyyy-MM-dd”, CultureInfo.InvariantCulture) > DateTime.ParseExact(“2000-02-02”, “yyyy-MM-dd”, CultureInfo.InvariantCulture)).CopyToDataTable()

You should have the filtered rows. (I put “3” on the linq because the index starts at 0, but adjust to the correct one if thats not the case)

I don’t understand how to filter

How’s that?
You do the steps i mentioned above and you will have your filtered rows in the “dtOutput” variable.
Then you use the variable as you want.

Hi @alexis.mendoza

Filter DataTable  
     Input: dtInput  
    Output  dtOutput 

Configure Columns
Filter Wizard
Column Name: Column4 Condition: > Value: 2000-02-02
In the place of column4 Give the column name of the datatable.

Hope it helps!!

I get this error when tried to use this method

No, I already tried to do it so it doesn’t filter it, it deletes all the columns

@alexis.mendoza

I think you are filtering with output columns
Try to filter only with rows as below

Try with filter datatable.
Hope it helps!!

If I did it like this, it doesn’t work, delete all the data

Hi @alexis.mendoza

Try this

InputDt.Select("[Date] >= #"+Str1.ToString +"#").CopyToDataTable

I hope it helps!!

Hi @alexis.mendoza

Please find below xaml for your reference.

Filter DataTable on Dates.zip (627.5 KB)

Regards,

@alexis.mendoza I don’t know if thats the case but try to import the “System.Globalization” from the imports panel.

Thanks everyone for your help.

I solved it in the following way.

First step, declare a date type variable with the date I need as a reference.
image

We declare a variable of type int32, which will function as a counter, we assign the value of the number of elements in our DT
image

We start a While loop that will iterate through all the elements of the DT with the conditional counter>0,


Inside the counter we start an IF , with the condition that appears in the SS. if the answer is yes then it does nothing to the element and subtracts 1 from the counter.

if the answer is No, then we eliminate the data and also subtract 1 from the counter.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.