Change date format in column

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.

I appreciate every bit of help, thank you

Hi @jntrk
Use the below method
Date.ParseExact(DT.Rows.item(“ColumnName”),“d.MM.yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“MM/d/yyyy”)

1 Like

Hi @jntrk,

Try this below code

Cdate(yourvariable.ToString).ToString(“MM/d/yyyy”)

Thanks!

1 Like

Sorry for the late response, I encountered with this issue,

Hi @jntrk

U can try this to change the date format to MM/d/yyyy

Datatable_variable.AsEnunerable().ToList().ForEach(Sub(row) row(columnName)= Date.ParseExact(row(“ColumnName”),“d.MM.yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“MM/d/yyyy”))

U can try this in a invoke code activitiy.

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.

Hope the information helps you

Regards

Nived N :robot:

Happy Automation :relaxed::relaxed::relaxed::relaxed:

1 Like