title: How can I pass DateTime format to MS sql server in a stored procedure?
body: <p>I hope you could help me in my project. 
  I have been trying to solve this issue long time ago and it doesn't work.</p>
  
  <p>I'm trying to pass a Date time from c# to MS sql server, note that the server 
  stored datetime with format '1900-01-01 00:00:00.000'</p>
  
  <p>it's work perfectly when I use it locally, but when I upload page into a server I get error. </p>
  
  <pre><code>  string connectionString;
              SqlConnection mySqlConnection;
              connectionString = ConfigurationManager.ConnectionStrings[("connectionNamr")].ConnectionString;
             mySqlConnection = new SqlConnection(connectionString);
              SqlCommand mySqlComd = new SqlCommand();
              SqlDataReader reader;
              mySqlComd.CommandText = "ProcedureName";    
              mySqlComd.CommandType = CommandType.StoredProcedure;
              mySqlComd.Connection = mySqlConnection;
              SqlParameter depParam = new SqlParameter("@colName1", SqlDbType.NVarChar, 255);
              SqlParameter empParam = new SqlParameter("@colName2", SqlDbType.NVarChar, 20);
              SqlParameter startDateParam = new SqlParameter("@EVcolName3", SqlDbType.DateTime);
              SqlParameter endDateParam = new SqlParameter("@colName4", SqlDbType.DateTime);
              SqlParameter filterParam = new SqlParameter("@colName5", SqlDbType.NVarChar, 20);
              depParam.Value = string.Empty;
              empParam.Value = employeeID;
              DateTime datet = new DateTime(year,month,day);
              string datet1 = datet.ToString();
              //string datet1 = datet.ToUniversalTime().ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'");
             // datet1 = datet1.Substring(0, 19);
              startDateParam.Value = Convert.ToDateTime(datet1.Trim()); ;
              endDateParam.Value = Convert.ToDateTime(datet1.Trim()); ;
              filterParam.Value = string.Empty; 
              mySqlComd.Parameters.Add(depParam);
              mySqlComd.Parameters.Add(empParam);
              mySqlComd.Parameters.Add(startDateParam);
              mySqlComd.Parameters.Add(endDateParam);
              mySqlComd.Parameters.Add(filterParam); 
              mySqlConnection.Open();
              mySqlComd.ExecuteNonQuery();
           reader = mySqlComd.ExecuteReader(CommandBehavior.CloseConnection);
  
              while (reader.Read())
  {
   attendance_date = reader["SITE_IN_TIME"].ToString();
  }
  
              mySqlConnection.Close();
              return attendance_date;
  
          }
          catch (Exception exp)
          {
              return "Error, Exception: " + exp;
          }
  </code></pre>