Skip to content

Commit 6c745ce

Browse files
author
Toby Allen
committed
Merge remote-tracking branch 'github/main'
2 parents 3523ec7 + 80c8746 commit 6c745ce

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

readme.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
# MSSQL Dateformat Fixer
22

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.
712

813
## Installation
914

@@ -40,4 +45,11 @@ on install and update.
4045
This is due to the fact that whenever `composer update` or `composer install` is run and the illuminate package
4146
is updated it will overwrite the `SqlServerGrammar.php` with the origional version, so it is necessary to call
4247
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

Comments
 (0)