How to change date format for the entire column of DataTable

I get the Data from Excel and stored to Datatable. In this one column is Date but it stored as many format so I want to convert as a same type of Date Format.

Hi @Ajith_143
Use DateTime.ParseExact(“Columnname” ,“mm-dd-yyyy”,System.Globalization.InvariantCulture.CultureInfo)
(or)
CDate(row(“ColumnName”).ToString
Thanks
Ashwin S

Where it to be use? @AshwinS2

@Ajith_143

try the below commands

DataTable dtCloned = dt.Clone();
dtCloned.Columns[0].DataType = typeof(Int32);

Regards
Ajay

Hi @Ajith_143

Use for each row in Dt
Use Assign and pass the query as DateVar=CDate(row(“ColumnName”).ToString

Thanks
Ashwin S

Thanks @Ajju
but, it helps to covert whole column to given date format

What is DateVar here

Hi @SyedShabaz03

Datetime type

Thanks
Ashwin S

IN an assign Activity ?

IN an assign Activity ?

dtCloned.Columns[0].DataType = typeof(Int32); if this is for Integer what would be for Date
tried dtCloned.Columns[0].DataType = typeof(Date) is not working

yes.

Thanks
Ashwin S

Use for each row in Dt —Okay
Use Assign and pass the query as DateVar=CDate(row(“ColumnName”).ToString
in Assign
LHS has to be a varaible where did i create the variable. You said its a date type , you are saying to put a Type in LHS or create a variable of type date and put it in LHS

Hi @SyedShabaz03

in LHS give it as DateVar and in Variable Panel change the data type as DateTime

Thanks
Ashwin S

With this the variables value gets changed to Date, But What i wnat to change the entire column in a DT to Date, Lets say there are 45 colmns in a DT read from excel i want 7 cols of them to a date format desired

1 Like

You can make use of the below custom activity to achieve this.Also, please go through the documentation if you have any doubts.

2 Likes