Converting all values in a column to Date format

I have used add data row to copy date values and paste in other datatable using (Cdate(row(“Date”).toString).ToString(“dd/MM/yyyy”)) as I need the date in dd/MM/yyyy format.
The format in output excel shows as General.

I tried using assign activity :- dt.columns(“new_date”).datatype= GetType(DateTime) and used sort datatable activity to sort on basis of “new_date” column. But sorting is not working and datatype is not getting changed to Date format

Hi @Shilpa_Mohanty

Refer the thread below and in the place of static date you need to pass the row value with the format!



If datatable has any data and try to change column type, it will throw exception.
So, can you share what you do step by step and expected result?

In general, DateTime type doesn’t have format information. It’ll make no sense to convert to dd/MM/yyyy format before input it as DateTime to datatable, i think.


1 Like

Hi @Shilpa_Mohanty

Please refer this to change column type,


I have one datatable, dt1
i have used build datatable and built dt2
i copied data from dt1 to dt2 using add data row in for each. When i did this, i see the column having Date is in general format and not date
i have to sort that date column
so i tried
1-dt.columns(“new_date”).datatype= GetType(DateTime)
2- sort datatable

But output is not coming as the complete column is in general format

Hi there,
So basically you need to convert to date each cell of this column correct?

That’s string, not datetime. Datetimes do not have formats. If you have a datetime column and want to convert it to string in the format dd/MM/yyyy, then create a new column with datatype string, For Each Row in Datatable, and Assign the new column’s value to CurrentRow(“OldCol”).ToString(“dd/MM/yyyy”)