How to replace date format quickly for two columns in data table variable?

i have one data table variable and 40 columns and i want to change date format from dd-MM-yyyy to MM/dd/yyyy HH:mm:ss and i need to change this format for only D column and x column so how do this with out using for each row because sometimes row line items goes as 65000 so it takes too much time

@sathish_Kumar6

Please try this

Dt.AsEnumerable.ToList.ForEach(sub(r) r("ColumnName") = Cdate(r("ColumnName").ToString).ToString("MM/dd/yyyy HH:mm:ss"))

Cheers

im getting error as
image

image

@sathish_Kumar6 please check your script seems you right ForDeach instead ForEach

@sathish_Kumar6

ColumnName to be replaced woth exact column name and you need to use ForEach

Cheers

okay sure will check and update

okay sure will check

Dt.AsEnumerable.ToList.ForEach(Sub(r) r(“Sales Invoice Date”) = CDate(r(“Sales Invoice Date”).ToString).ToString(“MM/dd/yyyy HH:mm:ss”)).CopyToDataTableDt.AsEnumerable.ToList.ForEach(Sub(r) r(“Delivery Date”) = CDate(r(“Delivery Date”).ToString).ToString(“MM/dd/yyyy HH:mm:ss”)).CopyToDataTable

image

Still getting error could u please take a look at this

date format @Anil_G
image

to change MM/dd/yyyy hh:mm:ss

@sathish_Kumar6

The expression provided is to be used in invoke code with dt as the in/out parameter

the date format in excel and when we read generally differs…check from locals panel after reading

cheers

i tried but im getting some errors so could you please share xaml if possible or could see error pic and let me know what to do ?

@sathish_Kumar6

Please give like this

Dt.AsEnumerable.ToList.ForEach(sub(r) r("ColumnName") = Cdate(r("ColumnName").ToString).ToString("MM/dd/yyyy HH:mm:ss"))

cheers

It is taking more than ten minutes and im not getting output so what to do?

@sathish_Kumar6

Do you mean its stuck there?

Or its taking some time?

Did you assign dt in the invole code arguments?

Cheers

It is taking time or dont know its stuck since it is having large data

when i tested with three row line items im getting this error

In this excel file i want to change it in d column and x column please refer this excel file
Testfile.xlsx (9.7 KB)

@sathish_Kumar6

Please open the locals panel and check the exception details from there

Cheers

i checked and idk where it goes wrng…