You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is supposed to be standard and in most instances it is, however MSSQL SERVER for some reason interprets the following date
2023-04-01 12:00:00
as 4th of January not the 1st of April as it should.
I have a large existing application that I have integrated very successfully with Laravel in the last 2 years that has a very large code base using hand crafted SQL Statements as well as new code written using Models and Eloquent.
If I change this function to the below format removing the - everything in my code works perfectly.
public function getDateFormat()
{
return 'Ymd H:i:s.v';
}
The only way for me to work with MSSQL and Laravel is to manually change the function above in the Illuminate framework. I do this with a Console command
This is run automatically every time composer update runs and for my application it works very nicely . However I feel like it should be possible to make a fix in the framework since this is a real issue.
Please note it should not matter what I do or do not have my MSSQL language set to or any other setting, the ISO standard is very clear the format is
YYYY-MM-DD
The issue here is MSSQL Server and since the grammar in question is specifically for MSSQL server I think it makes sense to change it.
I would be happy with a way of changing it in my code (via a config or something) but feel that ideally this format should be updated in the Illuminate library.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I'm wondering if I can get this discussed.
Laravel uses the ISO standard international date format
framework/src/Illuminate/Database/Query/Grammars/SqlServerGrammar.php
Lines 506 to 509 in 3a46fa3
This is supposed to be standard and in most instances it is, however MSSQL SERVER for some reason interprets the following date
as 4th of January not the 1st of April as it should.
I have a large existing application that I have integrated very successfully with Laravel in the last 2 years that has a very large code base using hand crafted SQL Statements as well as new code written using Models and Eloquent.
If I change this function to the below format removing the
-
everything in my code works perfectly.The only way for me to work with MSSQL and Laravel is to manually change the function above in the Illuminate framework. I do this with a Console command
https://github.com/tobya/BCSModel/blob/main/src/Console/CheckSQLGrammerDate.php
This is run automatically every time
composer update
runs and for my application it works very nicely . However I feel like it should be possible to make a fix in the framework since this is a real issue.Please note it should not matter what I do or do not have my MSSQL language set to or any other setting, the ISO standard is very clear the format is
YYYY-MM-DD
The issue here is MSSQL Server and since the grammar in question is specifically for MSSQL server I think it makes sense to change it.
I would be happy with a way of changing it in my code (via a config or something) but feel that ideally this format should be updated in the Illuminate library.
I am happy to make the change if decided.
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions