Query on Datatable (Filter)

Hello All,

i have some problem. so i have datatable which one have one column that have values ‘XXX1\MONTH\YEAR\XXXX’ so i have to filter it by specific month to Datetimenow.
is this sequence solve all my problem?
image

example on query :
select * from table_A where column_A like ‘%\MONTH\YEAR%’

Thankyou

1 Like

Hi @aliaga

System.DateTime.Now.ToString(“MM/dd/yyyy”)

Is that what you need?

1 Like

Hi @KMota,

no, i have to get the datatable who has column like ‘XXX1\MONTH\YEAR\XXXX’ .

example on query :
select * from table_A where column_A like ‘%\MONTH\YEAR%’

Thankyou

1 Like

Hello,
try

NewDt = Dt.Select(“MyColumn=’”+ System.DateTime.Now.ToString(“MM/yyyy”).tostring+"’")

1 Like

NewDt is DataRow

1 Like

Hi @aliaga
Use Following code in assign Yourdatatable.AsEnumerable().Where(Function(x) CStr(x("YourColumnName")).Contains("‘XXX1\MONTH\YEAR\XXXX’")).CopyToDataTable
assign this to a datatable variable. you will get your desired output.

Regards

2 Likes

Hi @aliaga,

Please use in this way …
assign1

The right side of assign contains this value…

Cheers.
Vashisht.

1 Like

Hi @Vashisht,

is that sequence create output all datatable who have column like ‘xxx\MM\yyyy’.
the out put will be like datatable :
001\11\2019\123 col_A col_B
002\11\2019\321 col_A col_B
003\11\2019\234 col_A col_B

btw i’ll try this first.

Thankyou

Hi @Vashisht,

i got an error like this :
image

sequence :

variable dt as datatable

Thankyou

Hi @jitendra_123,
i got an error using that code :

@aliaga
you are getting this error because there are empty rows in your datatable so before executing this query remove those empty rows using Select Query. so use following code in Assign
((Yourdattable.Select("YourColumnName<>'' ").CopyToDataTable).AsEnumerable().Where(Function(x) CStr(x("YourColumnName")).Contains("‘XXX1\MONTH\YEAR\XXXX’"))).CopyToDataTable

Regards