Skip to content

MS SQL Server DateTime localization problems #653

@vertexer

Description

@vertexer

I have to use the german edition of MS SQL Server 2012 for a client project.

If I use DateTime columns like timestamps I get the following error:

 [Exception]
 SQLSTATE[22007]: [Microsoft][SQL Server Native Client 11.0][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]
  ([username], [password], [updated_at], [created_at]) values (?, ?, ?, ?)) (Bindings: array (
   0 => 'username',
   1 => 'hash',
   2 =>
   DateTime::__set_state(array(
      'date' => '2013-03-21 19:11:11',
      'timezone_type' => 3,
      'timezone' => 'Europe/Berlin',
   )),
   3 =>
   DateTime::__set_state(array(
      'date' => '2013-03-21 19:11:11',
      'timezone_type' => 3,
      'timezone' => 'Europe/Berlin',
   )),
 ))

I had to change Illuminate\Database\Query\Grammars\SqlServerGrammar to get it working:

    public function getDateFormat()
    {
        return 'd.m.Y H:i:s.000';
    }
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions