I have a DB server running some version of MS SQL - not my choice, just a reality. My Laravel 5.5 instance is on a Debian Linux system and is using the Microsoft ODBC drivers for Linux and sqlsvr/pdo_sqlsvr for PHP. This part at least works as I can migrate a table and read and write data to tables via models... kind of.
The crux of my problem is dates, or more specifically writing dates to the table. The stickiest of which seem to be created_at and updated_at.
[Microsoft][ODBC Driver 13 for SQL Server][SQL Server] Conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
Looking at the actual SQL in the error the dates are as I'd expect 2018-02-14 21:19:00.000
.
So I dug around a bit and came up with adding the getDateFormat()
function to my model
public $timestamps = true;
public function getDateFormat() {
return 'd/m/Y H:i:s';
}
Now it writes dates into the SQL table.
But when it tries reading from the table I get:
The separation symbol could not be found Trailing data
So I seem to have a choice I can write dates or I can read dates, but only by changing the model.
It seems to suggest that the dates being read from SQL without any getDateFormat() change works. But in order to write them I must use the British d/m/Y format. So I must write in d/m/Y but must read in m-d-Y format???
Can anyone give me any pointers as to what the problem is? SQL Server or ODBC driver is my suspicion, but no clue how to change the date formatting there.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community