Hi,
i need to convert date format 1/16/2010 10:10:2011 AM to 16/1/2010 10:10:2011 AM after that i need to put values to database too as datetime datatype.
error I am getting :
"The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. The statement has been terminated. "
string dd = "dd/MM/yyyy";
string ti = "HH:mm:ss tt";
string d = DateTime.Now.ToString(dd);
string mints = DateTime.Now.ToString(ti);
string result = d+""+mints;
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "insert into tablename Values(7,5,'"+result+"')";
con.Open();
cmd.ExecuteNonQuery();
con.Close();