title: Error sql:The conversion of a varchar data type to a datetime data type resulted in an out-of-range value
body: <p>I tried to enter the date of the current day with the following code:</p>
  
  <pre><code>string now = (DateTime.Today.Day + "/" + DateTime.Today.Month + "/" + DateTime.Today.Year).ToString();
  string tm = (DateTime.Today.Hour + ":" + DateTime.Today.Minute).ToString();
  string sql2 = string.Format("INSERT INTO Kabala2 (Nu_kabala,Ma_num,Sk,Seif_hacnasa,Seif_name,Date) VALUES('{0}','{1}','{2}','{3}','{4}','{5}')", n, Session["Ma_num"], lprice, lkod,des, now );
  Dal.DoQuery(sql2);
  </code></pre>
  
  <p>when I run this code it shows me the error in the title :</p>
  
  <blockquote>
    <p>The conversion of a varchar data type to a datetime data type resulted
    in an out-of-range value</p>
  </blockquote>
  
  <p>How do I solve it? </p>
  
  <p>------------------edit</p>
  
  <p>i changed it  to:<code>string now = DateTime.Today.ToString("yyyy-MM-dd HH:mm:ss");</code> and it works.</p>
  
  <p>now i  have another problem, when i run the code below it shows me the error:Error converting data type varchar to numeric.</p>
  
  <pre><code>string now = DateTime.Today.ToString("yyyy-MM-dd HH:mm:ss");
      string tm = DateTime.Now.ToString("HH:mm:ss");
      string sql = string.Format("INSERT INTO Kabala1 (Nu_kabala,Ma_num,Date,Time,Total,Status,Name,User_n) VALUES('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')", n, Session["Ma_num"], now, tm, lprice, "ddffs", Session["user"], "ddffs");
      Dal.DoQuery(sql);
      string sql2 = string.Format("INSERT INTO Kabala2 (Nu_kabala,Ma_num,Sk,Seif_hacnasa,Seif_name,Date) VALUES('{0}','{1}','{2}','{3}','{4}','{5}')", n, Session["Ma_num"], lprice, lkod, des, now);
      Dal.DoQuery(sql2);
      string sql3 = string.Format("INSERT INTO Kabala3 ((Nu_kabala,Msd,Ma_num,Kind_pay,Name_pay,Date_pay,Sk,Ms_sek,Snif,Bank,Date_klita,Seif) VALUES('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}')", n,"1", Session["Ma_num"],"13", "ddffds", now, lprice, this.card.Text, this.mm.Text, this.yy.Text, now, lkod);
      Dal.DoQuery(sql3);
  </code></pre>