title: Error converting nvarchar to datetime data type using Laravel and MSSQL
body: <p>I installed successfully Laravel on IIS. I connected the MSSQL DB also successfully with laravel. I run the artisan command <code>php artisan make:auth</code> and <code>php artisan migrate</code>.To make a login/register pages. Now when i register a new user i get an error.:</p>
  
  <blockquote>
    <p>SQLSTATE[22007]: [Microsoft][ODBC Driver 17 for SQL Server][SQL
    Server]Bei der Konvertierung eines nvarchar-Datentyps in einen
    datetime-Datentyp liegt der Wert außerhalb des gültigen Bereichs.
    (SQL: insert into [users] ([name], [email], [password], [updated_at],
    [created_at]) values (john doe, j.doe@example.com,
    $2y$10$zPpJKp.clN8/SrhBhrupmO1ydWFb6UmrAUaD0Wid7fQHt85ieSwNi,
    2018-04-24 10:03:26.286, 2018-04-24 10:03:26.286))</p>
  </blockquote>
  
  <p>this translated to english:</p>
  
  <blockquote>
    <p>The conversion of a nvarchar data type to a datetime data type resulted in
    an out-of-range datetime value."</p>
  </blockquote>
  
  <p>my migration look like this:</p>
  
  <pre><code>public function up()
      {
          Schema::create('users', function (Blueprint $table) {
              $table-&gt;increments('id');
              $table-&gt;string('name');
              $table-&gt;string('email')-&gt;unique();
              $table-&gt;string('password');
              $table-&gt;tinyInteger('active')-&gt;default(1);
              $table-&gt;rememberToken();
              $table-&gt;timestamps();
          });
      }
  </code></pre>
  
  <p>and my db after migration look like this:
  <a href="https://i.stack.imgur.com/8AoIl.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8AoIl.jpg" alt="enter image description here"></a></p>
  
  <p>In MSSQL i'm using the <code>SQL_Latin1_General_CP1_CI_AS</code>. 
  DO have anybody any idea whats the problem is?</p>
  
  <p><strong>UPDATE</strong>
  'Quick solution: I changed the mssql columns created_at and updated_at to nvarchars(50)</p>
  
  <p><strong>UPDATE1</strong>
  Another solution is to override it with this method</p>
  
  <pre><code>public function fromDateTime($value)
  {
      // Only for MSSQL
      if(env('DB_CONNECTION') == 'sqlsrv') {
          return Carbon::parse(parent::fromDateTime($value))-&gt;format('Y-d-m H:i:s:000');
      }
      return $value;
  }
  </code></pre>