SreeRam Kondagorla

SreeRam Kondagorla

  • NA
  • 234
  • 56.2k

Set Data Type MM/DD/YYYY for Data table Column

Sep 12 2017 7:22 AM
I have data table with columns name,date.
now i'm giving the datatypes for column name =string, for date =datetime.
after that i'm adding the datarow. the date value is having 12-25-2109
after adding to data table im getting as 12-25-09 07:00:57:.850 .
but i want to get the the values as 12-25-2019 07:00:57:.850 .because the data type of the column is datetime.how can i get the required format.pla help me.
 
DataTable dtCloned = sourceDataSet.Tables[0].Clone();
for (int i = 0; i < dtCloned.Columns.Count; i++)
{
if (dtCloned.Columns[i].ColumnName == "ExpirationDate")
dtCloned.Columns[i].DataType = typeof(DateTime);
else if (dtCloned.Columns[i].ColumnName == "Amount")
dtCloned.Columns[i].DataType = typeof(Decimal);
else
dtCloned.Columns[i].DataType = typeof(String);
}
 

Answers (3)