Tech
Forums
Jobs
Books
Events
Live
Interviews
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
3
Reply
Set Data Type MM/DD/YYYY for Data table Column
SreeRam Kondagorla
Sep 12 2017 7:22 AM
200
Reply
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);
}
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
3
)
Next Recommended Forum
See Details by Employee Code.
What is the objective of code benchmarking and what it does