Filter data table by column with different data types

Hello,

I have a problem with filtering data table via column where I have values such as:

X
04/23/2018 00:00:00
FC Done,Please check

When I do it like
new_dt = old_dt.Select("[Column] = 'X'").CopyToDataTable it works perfectly.

Unfortunately when I try to filter X and FC Done,Please check like:
new_dt = old_dt.Select("[Column] in ('X','FC Done,Please check')").CopyToDataTable I get an error:
image
What is interesting when I try to filter “FC Done,Please check” with
new_dt = old_dt.Select("[Column] = 'FC Done,Please check'").CopyToDataTable I get the same error.
It seems something is wrong with data types or so.
Do you have any idea how I could deal with this problem?

Much thanks in advance.

1 Like

@Rafal_Bartko

Try this
new_dt = old_dt.Select(“Convert([Column],System.String) = ‘FC Done,Please check’”).CopyToDataTable

Sorry I forget to add Convert.

Regards,
Mahesh

Unfortunately, it doesn’t work.
I get error that it cannot find column [Column,System.String]

Regards,
Rafal

@Rafal_Bartko

You have to replaca the Column by your Column Name

Regards,
Mahesh

Yeah I did that of course.
It still takes [My column name,System.String] as whole column name.

Regards,
Rafal

@Rafal_Bartko

Can you just share the screen shot

Yes, sure.
This is what I get:
image

The code I used in Assign activity:
dt_schedule.Select("[Formal Check,System.String] = 'FC Done,Please check'").CopyToDataTable

Regards,
Rafal

Hey @Rafal_Bartko

Try this
dt_schedule.Select(“Convert([Formal Check],System.String) = ‘FC Done,Please check’").CopyToDatatable

Regards,!!
Aksh

2 Likes

Hello!
I’ve tried and got such exception:
image

Regards,
Rafal

Hey @Rafal_Bartko

Corrected -dt_schedule.Select(“Convert([Formal Check],System.String) = ‘FC Done,Please check’").CopyToDatatable

sample.xaml (6.8 KB)

Regards,!!
Aksh

3 Likes

Hello @aksh1yadav

It works! Thank you very much.
So it has converted [Formal Check] column’s type into String and then selected, right?
Is this VB?

Regards,
Rafal

Yes but you should use when your column type is different. so in my example case the column type is by default a string so even if i will omit convert and use only simple column name and string to compare it will work :slight_smile:

Regards,!!
Aksh