From 2434ca41a1f60bc9a5518b73e4fedf7c1711aea8 Mon Sep 17 00:00:00 2001 From: Toby Allen Date: Thu, 28 Dec 2023 22:38:29 +0000 Subject: [PATCH 1/2] Update readme.md --- readme.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/readme.md b/readme.md index 8a8db4a..4f35b93 100644 --- a/readme.md +++ b/readme.md @@ -1,9 +1,14 @@ # MSSQL Dateformat Fixer -There is an international date format Y-m-d that is supposed to be universal, however the MSSQL implementation is flawed -and is not universal and incorrect interprets it as Y-d-m which is beyond idiotic. -Laravel uses Y-m-d as their international format, which can lead to errors depending on SQL SERVER Settings. -This command checks the vendor directory for the file and updates it if required. +There is an international date format `Y-m-d` that is supposed to be universal, however the MSSQL implementation is flawed +and is NOT universal and incorrectly interprets `Y-m-d` as `Y-d-m` which is beyond idiotic. +Laravel uses `Y-m-d` as their international format, which can lead to errors depending on SQL SERVER Settings. + +There is one format `Ymd` which is absolutely gauranteed to always be interpreted by SQLServer as `Ymd`. This command patches the file in +illuminate library to use `Ymd` instead of `Y-m-d`. I [Requested]() that the change be made in the illuminate library but it was felt the change +was too big to be made. + +I hope this is helpful to those of you out there using MSSQL with PHP/Laravel. ## Installation @@ -40,4 +45,4 @@ on install and update. This is due to the fact that whenever `composer update` or `composer install` is run and the illuminate package is updated it will overwrite the `SqlServerGrammar.php` with the origional version, so it is necessary to call the command whenever this has the potential of happening. If no change has been made to the file it will -not be modified. \ No newline at end of file +not be modified. From 80c8746356f55bf61e27a0360325a87c886e75a8 Mon Sep 17 00:00:00 2001 From: Toby Allen Date: Thu, 28 Dec 2023 22:44:26 +0000 Subject: [PATCH 2/2] Update readme.md --- readme.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 4f35b93..c5677d8 100644 --- a/readme.md +++ b/readme.md @@ -1,11 +1,11 @@ # MSSQL Dateformat Fixer -There is an international date format `Y-m-d` that is supposed to be universal, however the MSSQL implementation is flawed +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 and is NOT universal and incorrectly interprets `Y-m-d` as `Y-d-m` which is beyond idiotic. Laravel uses `Y-m-d` as their international format, which can lead to errors depending on SQL SERVER Settings. There is one format `Ymd` which is absolutely gauranteed to always be interpreted by SQLServer as `Ymd`. This command patches the file in -illuminate library to use `Ymd` instead of `Y-m-d`. I [Requested]() that the change be made in the illuminate library but it was felt the change +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 was too big to be made. I hope this is helpful to those of you out there using MSSQL with PHP/Laravel. @@ -46,3 +46,10 @@ This is due to the fact that whenever `composer update` or `composer install` is is updated it will overwrite the `SqlServerGrammar.php` with the origional version, so it is necessary to call the command whenever this has the potential of happening. If no change has been made to the file it will not be modified. + +#### Further reading on why this is necessary + +This is discussed in several places online + + - [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) + - [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)