Hi guys,, I'm try to save data in sql server with DateTime format, I'm get error like this
SqlException: 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.
in the Controller I have been try to + Convert.ToDateTime(pasienModel.Tanggal_Lahir) + but not working. Any help could be appreciated.

this is the PasienModel.cs
- [DataType(DataType.DateTime)]
- [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true, NullDisplayText = "NULL")]
- public Nullable<System.DateTime> Tanggal_Lahir { get; set; }
this is the PasienController.cs
- [HttpGet]
- public IActionResult TambahData()
- {
- return View();
- }
- public IActionResult TambahData(PasienModel pasienModel)
- {
- if (ModelState.IsValid)
- {
- using (SqlConnection con = new SqlConnection(_configuration.GetConnectionString("db_klinik")))
- {
- using (SqlCommand cmd = new SqlCommand("Insert Into Pasien (Nama_Pasien,Alamat,Jenis_Kelamin,Tanggal_Lahir,Status) Values ('" + pasienModel.Nama_Pasien + "','" + pasienModel.Alamat + "','" + pasienModel.Jenis_Kelamin + "','" + Convert.ToDateTime(pasienModel.Tanggal_Lahir) + "','" + pasienModel.Status + "')", con))
- {
- con.Open();
- cmd.Connection = con;
- cmd.CommandType = CommandType.Text;
- cmd.ExecuteNonQuery();
- return RedirectToAction("Index", "Dokter");
-
- }
- }
- }
- else
- {
- return View(pasienModel);
- }
- }
this is the View TambahData.cshtml
- <div class="form-group row">
- <label asp-for="Tanggal_Lahir" class="col-sm-2 col-form-label">Tanggal Lahir</label>
- <div class="col-sm-10">
- @Html.TextBoxFor(model => model.Tanggal_Lahir, new { @class = "form-control datepicker", placeholder = "Enter Date", id = "Date", autocomplete = "off" })
- <span asp-validation-for="Tanggal_Lahir" class="text-danger"></span>
- </div>
- </div>
this is the Javascript to show calender
- <script src="~/plugins/jquery/jquery.min.js"></script>
- <link href="~/JqueryCalender/jquery-ui-1.12.1.custom/jquery-ui.min.css" rel="stylesheet" />
- <script src="~/plugins/moment/moment.min.js"></script>
- <script type="text/javascript">
- $(document).ready(function () {
- $('.datepicker').datepicker({
- dateFormat: "yy/mm/dd"
- });
- });
- </script>