title: Dapper SqlDateTime overflow using GETDATE() in SQL Server
body: <p>I have the following code which gets the input from a form and calls a stored procedure to store it in a database.</p>
  
  <pre><code> [HttpPost]
   public ActionResult Index(GuestMessage model)
   {
          if (ModelState.IsValid)
          { 
              using(IDbConnection conn = DatabaseAcess.OpenConnection())
              {
                  const string storedProcedure = "dbo.InsertMessage";
                  conn.Execute(storedProcedure, new GuestMessage { Name = model.Name, Email = model.Email, Message = model.Message }, null, null, CommandType.StoredProcedure);
  
                  return View("ThankYou");
              }
           }
          return View();
  }
  </code></pre>
  
  <p>There are three fields, <code>Name</code>, <code>E-mail</code> and <code>Message</code> that have to be filled in by the user. In the database I store the data that the user enters, from these three fields, and the time of the entry using a stored function called dbo.Insert Message. </p>
  
  <pre><code>BEGIN
    BEGIN TRAN
  
    SET NOCOUNT ON;
  
    DECLARE @GuestID int;
    INSERT INTO Guest(Name, Email) VALUES (@Name, @Email);
    SELECT @GuestID = scope_identity();
  
    INSERT INTO Message (EntryDate, GuestID, Message, Status) 
    VALUES (GETDATE(), @GuestID, @Message, 2);
  
    COMMIT TRAN
  END
  </code></pre>
  
  <p>Notice that I do not pass the entry date and time as an input parameter to the stored procedure since there is no need for that. I use the built-in function <code>GETDATE()</code> in SQL Server to determine the time a user has entered a message.</p>
  
  <p>However, whenever I try to enter a message I get the following error:</p>
  
  <blockquote>
    <p>SqlDateTime overflow. Must be between 1/1/1753 12:00:00AM and 12/31/9999 11:59:59PM</p>
  </blockquote>