title: Convert C# DateTime to SQL Date and insert with stored procedure
body: <p>I'm trying to use the Date type on SQL because I only need the YYYY-MM-DD format, the problem is that I can't parse the DateTime into the SQL Date, I leave the code of SQL and C#</p>
  
  <p>--SQL</p>
  
  <p>Table:</p>
  
  <pre><code>CREATE TABLE CALENDAR(
      DateID int IDENTITY(1,1) PRIMARY KEY (DateID),
      Day Date
  );
  
  CREATE PROCEDURE CreateDate
  @Day, @haserror bit out
  AS
  begin try
      set @haserror = 0
      insert into CALENDAR(Day)
      values
      (@Day)
  end try
  begin catch
      set @haserror = 1;
  end catch
  </code></pre>
  
  <p>--C#</p>
  
  <pre><code>public bool CreateDayCalendar(DateTime date)
  {
      var result = false;
      try
      {
          if (_client.Open())
          {
              var command = new SqlCommand
              {
                  Connection = _client.Connection,
                  CommandText = "CreateDate",
                  CommandType = CommandType.StoredProcedure
              };
  
              var par1 = new SqlParameter("@Day", SqlDbType.Date)
              {
                  Direction = ParameterDirection.Input,
                  Value = **How do I put the DateTime here**
              };
  
              var par2 = new SqlParameter("@haserror", SqlDbType.Bit)
              {
                  Direction = ParameterDirection.Output
              };
  
              command.Parameters.Add(par1);
              command.Parameters.Add(par2);
  
              result = !Convert.ToBoolean(command.Parameters["@haserror"].Value.ToString());
          }
      }
      catch (Exception e)
      {
          result = false;
      }
      finally
      {
          _client.Close();
      }
  
      return result;
  }
  </code></pre>
  
  <p>I don't know if the problem is how to parse the DateTime to Date, or do I have to change the property Day inside Calendar to another type?}</p>
  
  <p>--EDIT</p>
  
  <p>I forgot a line of code </p>
  
  <pre><code>command.ExecuteNonQuery();
  </code></pre>
  
  <p>There was no mistake while parsing</p>