How to use FilterDateTable to filter days of a specfic date using 'contains' not working

DataTable has date values in the format :7/25/2019 12:00:00 AM
Date value being searched is of the format:7/25/2019

In FilterDataTable the column 3 contains the date values. Using ‘contains’ does not find the searched Date value.
But if i use ‘if’ condition to check if the date string is present it returns ‘true’

csvData.Rows(3).Item(3).ToString.Contains(dateVal) --> this works

Using FilterDataTable does not pull up any data. Please let me know if there is a way to use filterDataTable to pull up rows of only a particular date.

Hi
Fine we can use select method
Like this
Yourdatatablename = yourdatatablename.Select(“[yourcolumnname]= # “ + yourvariable + “ # “)

But make sure that if column has 7/25/2019 12:00:00 then the variable should also have the same format and not just 7/25/2019

Hope this would help you
Cheers @mailsmithash

Yes i have used something similar but getting an error message . “Assign: Cannot perform ‘=’ operation on System.String and System.DateTime.”,"

ALData.Select("[Column3]=#"+ dateVal.ToString+"#").CopyToDataTable

You were almost right
May I know what is the datatype of column3
Cheers @mailsmithash

The Datatable is built from a CSV file which contains Date in the format ‘7/25/2019 12:00:00’ Not sure how to know the datatype of that column

Its System.DateTime the dataType of Column3

The issue is resolved now. Using the below in FilterTable

1 Like

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