i am copying datarow from one table to another datatable column structrure are not same hence i use
DataTable dt = new DataTable();
dt.Columns.Add("START DATE", typeof(System.DateTime));
dt.Columns.Add("END DATE",typeof(System.DateTime));
DataRow row = dt.NewRow();
//copy row from old table
foreach (DataRow dr in WorksheetInfo.Rows)
{
row = dt.NewRow();
row[0] = dr["StartDate"].ToString();
row[1] = dr["EndDate"].ToString();
dt.Rows.Add(row);
}
dt.AcceptChanges();
i want
date should be display in format 24/12/2012 12:00:00 its requirement of project can not change.
but now
my current date showing in datable is 12/24/2012 only
I try everything example
1) string dtenddate = dr["EndDate"].ToString();
DateTime dtendate = Convert.ToDateTime(dtenddate);
row[1] = dtendate;
2)string dtdate = String.Format("{0 d/M/yyyy HH:mm:ss}",Convert.ToDateTime(dr["EndDate"]));
row[1] = dtdate;
any many more
last option i try for array split event if here it show error
DateTime dtstart = Convert.ToDateTime(dr["EndDate"]); string[] strDateTime = dtstart.ToString("dd/MM/yyyy").Split('/');
string txtDate = strDateTime[0];
string txtMonth = strDateTime[1];
string txtYear = strDateTime[2];
but it showing
error as string was not recognise as valid date time,anyone have idea how to get my requirement