|
1 | 1 | # MSSQL Dateformat Fixer
|
2 | 2 |
|
3 |
| -There is an international date format Y-m-d that is supposed to be universal, however the MSSQL implementation is flawed |
4 |
| -and is not universal and incorrect interprets it as Y-d-m which is beyond idiotic. |
5 |
| -Laravel uses Y-m-d as their international format, which can lead to errors depending on SQL SERVER Settings. |
6 |
| -This command checks the vendor directory for the file and updates it if required. |
| 3 | +There is an [international date format (ISO standard)](https://www.iso.org/iso-8601-date-and-time-format.html) (YYYY-MM-DD) `Y-m-d` that is supposed to be universal, however the MSSQL implementation is flawed |
| 4 | +and is NOT universal and incorrectly interprets `Y-m-d` as `Y-d-m` which is beyond idiotic. |
| 5 | +Laravel uses `Y-m-d` as their international format, which can lead to errors depending on SQL SERVER Settings. |
| 6 | + |
| 7 | +There is one format `Ymd` which is absolutely gauranteed to always be interpreted by SQLServer as `Ymd`. This command patches the file in |
| 8 | +illuminate library to use `Ymd` instead of `Y-m-d`. I [Requested](https://github.com/laravel/framework/issues/49074) that the change be made in the illuminate library but it was felt the change |
| 9 | +was too big to be made. |
| 10 | + |
| 11 | +I hope this is helpful to those of you out there using MSSQL with PHP/Laravel. |
7 | 12 |
|
8 | 13 | ## Installation
|
9 | 14 |
|
@@ -40,4 +45,11 @@ on install and update.
|
40 | 45 | This is due to the fact that whenever `composer update` or `composer install` is run and the illuminate package
|
41 | 46 | is updated it will overwrite the `SqlServerGrammar.php` with the origional version, so it is necessary to call
|
42 | 47 | the command whenever this has the potential of happening. If no change has been made to the file it will
|
43 |
| -not be modified. |
| 48 | +not be modified. |
| 49 | + |
| 50 | +#### Further reading on why this is necessary |
| 51 | + |
| 52 | +This is discussed in several places online |
| 53 | + |
| 54 | + - [sqlblog.org/2009/10/16/bad-habits-to-kick-mis-handling-date-range-queries](https://sqlblog.org/2009/10/16/bad-habits-to-kick-mis-handling-date-range-queries) |
| 55 | + - [stackoverflow.com/questions/19565320/why-is-sql-server-misinterpreting-this-iso-8601-format-date](https://stackoverflow.com/questions/19565320/why-is-sql-server-misinterpreting-this-iso-8601-format-date) |
0 commit comments