LINQ Query Troubleshooting

Hi Team Facing issue on below query
dtFrstChkSuccessRecords.AsEnumerable.Where(Function(x) x.Item(If((“Column Name”).Contains(“”),(“Column Name”),If((“Column Name”).Contains(dd.MM.yyyy),Datetime.ParseExact((“Column Name”),“dd.MM.yyyy”,System.Globalization.CultureInfo.InvariantCulture).Tostring(“MM/dd/yyyy”))).CopyToDataTable
Error giving as expectecd “)”

Guys guide me where i am missing the “)”

Hi @Mahii

Welcome to uipath community

Try with this expression

DTInput1.AsEnumerable.Where(Function(x) x.Item(If(("Column Name").Contains(""),("Column Name"),If((“Column Name”).Contains("dd.MM.yyyy"),Datetime.ParseExact(("Column Name"),"dd.MM.yyyy",System.Globalization.CultureInfo.InvariantCulture).Tostring("MM/dd/yyyy"))))).CopyToDataTable

Regards
Gokul

Hi,

There seems several problems in your expression.

First, inner If doesn’t have 3rd argument.
Second, does x.item() returns boolean? If not, should add condition.
Third, it seems variable is missing in front of (“Column Name”) Is it good?

Regards,

1 Like

dtFrstChkSuccessRecords.AsEnumerable.Where(Function(x) x.Item(If((“Column”)=(“”),(“Column”),Datetime.ParseExact((“Column”),“dd.MM.yyyy”,System.Globalization.CultureInfo.InvariantCulture).Tostring(“MM/dd/yyyy”))))).CopyToDataTable

above code is giving error as one or more inferno possible with shared code

i am using mentioned codes,but dont know why it is giving the end of expression expected

Hi @Mahii ,

Could you let us know what do you want the Query to perform ?

Maybe we can understand better if a brief Explanation is provided on the requirement.

i want that when cloumn is blank than it should give blank value in same column,but if it is date then it shall convert date in required format in same column

@Mahii ,

If that is the case, then the query that you are using wouldn’t really work. Also, The mentioned statement points out again to the Input Data itself.

Do you want to filter any values based on date ? Do you want to remove the empty values present in the data ?

If you could provide us with Input data and it’s expected output, we would be able to help you better.

No i am not filtering, Expected output be like below
Column Name
06/05/2020
06/05/2020
06/05/2020
06/05/2020

06/14/2021
07/15/2022

input is dd.MM.yyyy format i am converting that and if it is blank i cannot convert hence writing same value, in this case it is (“”)

Hi,

The following might help you.

dtFrstChkSuccessRecords.AsEnumerable.ToList.ForEach(
Sub(r)
    Dim d As DateTime
    If DateTime.TryParseExact(r("Column2").ToString,"d.M.yyyy",System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None,d)
        r("Column2")=d.ToString("MM/dd/yyyy")
    End If
End Sub
)

Sample20221125-7.zip (3.0 KB)

Regards,