According to your comment to the answer of Andoni Alda, it seems that your error is more in the recording than in the query, that is, you are trying to record a string instead of a DateTime. It may work on your computer when you record it as dd / mm / yyyy in string format because your database server is configured for Spanish and therefore does not give you problems but when recording as mm / dd / yyyy you can find dates of type 03/31/2016 that will give you an exception (apart from the fact that the rest of the dates will be badly recorded).
If you are recovering the date of a DatePicker control or similar, the value that you return is already a DateTime and this is the one that you should record without formatting it previously. If this is not the case and you are getting the string from a file or similar, you can always convert it to DateTime using a Parse or TryParse method:
DateTime dtmDate = DateTime.Parse(strFecha);
Once you have a dateTime, you do not have to convert it back to a string, simply use Command parameters in your recording. That is, instead of:
string strSQL = string.format("INSERT INTO tabla (Fecha) VALUES {0:dd-MM-yyyy HH:mm}", dtmDate);
using (SqlConnection objConnection = new SqlConnection(connectionString))
{ command = new SqlCommand(strSQL, objConnection);
objConnection.Open();
command.Execute(strSQL);
}
Use parameters:
string strSQL = "INSERT INTO tabla (Fecha) VALUES @FE_Fecha";
using (SqlConnection objConnection = new SqlConnection(connectionString))
{ command = new SqlCommand(strSQL, objConnection);
command.Parameters.Add("@FE_Fecha", SqlDbType.DateTime);
command.Parameters["@FE_Fecha"].Value = dtmDate;
objConnection.Open();
command.Execute();
}
Where @FE_Date is the parameter that SQL Server will use as a date.
Note: I have written the code without testing, see MSDN for more information.
Note 2: Another option that I have used for a long time if you do not want to use parameters (which I would not understand) is to record from a string is to do it in canonical ODBC format, that is: yyyy-mm-dd hh: mm: ss (2016-12-03 19:23:00 for example)