Hey everyone I have a column in a datatable where the format of date is d.MM.yyyy , I want to change it all values in this column to MM/d/yyyy and I cannot use for each activity because there are to many rows to take this action for each row. I might change the “.” with “/” using .Replace but I have no idea how to change the position of day and month.
Hi @jntrk
Use the below method
Date.ParseExact(DT.Rows.item(“ColumnName”),“d.MM.yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“MM/d/yyyy”)
But when u write the datatable in excel it is better to add the data in text format rather than adding in datetime because of excel cell may be formated in one date format, like they may be formated in dateformat of dd.MM.yyyy but even when u paste the date in format of MM/dd/yyyy it will appear as dd.MM.yyyy.
Before writing the datatable to excel try to convert the date format in excel to.required one either manually or using Balareva activitiy.
it seems i had done some mistakes from my side in the code
kindly try with this code Datatable_variable.AsEnumerable().ToList().ForEach(Sub(row) row(columnName)= DateTime.ParseExact(row(“ColumnName”).ToString, “d.MM.yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“MM/d/yyyy”))