SQLSTATE[22007]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Converting a varchar data type to a datetime data type created an out-of-bounds value. (Connection: sqlsrv, SQL: insert into [users] ([name], [email], [password], [updated_at], [created_at]) values (yyyy, [email protected], $2y$12$TOh49tHTJSUzlxE9omOALOiG2FK/pd/MgGVqCSiaoNIfW6dFmX1rW, 2025-01-31 08:15:16.408, 2025-01-31 08:15:16.408))
The migration with $table->timestamps(); created the columns with datetime as type and set this datetime format 'Y-m-d h:i:s.u' when we try an insert but sqlsrv allows 'Y-m-d h:i:s' for datetime type. How can I fix it?
SQLSTATE[22007]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Converting a varchar data type to a datetime data type created an out-of-bounds value. (Connection: sqlsrv, SQL: insert into [users] ([name], [email], [password], [updated_at], [created_at]) values (yyyy, [email protected], $2y$12$TOh49tHTJSUzlxE9omOALOiG2FK/pd/MgGVqCSiaoNIfW6dFmX1rW, 2025-01-31 08:15:16.408, 2025-01-31 08:15:16.408))
The migration with $table->timestamps(); created the columns with datetime as type and set this datetime format 'Y-m-d h:i:s.u' when we try an insert but sqlsrv allows 'Y-m-d h:i:s' for datetime type. How can I fix it?
Thanks for all of your contributions. For resolving it definitively, I used $table->timestamps(2) instead of $table->timestamps() in the migration file It finally works successfully.

yyyy-MM-dd hh:mm:ssis an ambiguous string format for(small)datetime. You are better off usingyyyyMMdd hh:mm:ssoryyyy-MM-ddThh:mm:ss. If you aren't American then your literal,'2025-01-31 08:15:16.408', would be treated as the 1st day, of the 31st month, of the 2025th year; obviously there aren't 31 months and so it errors. – Thom A Commented Jan 31 at 9:43"Y-m-dTh:i:s.u"or whatever to match the format thom wrote is unambigious – siggemannen Commented Jan 31 at 10:36