Jun-20-2019, 11:57 AM
Hi everybody,
I've got a question. I'm creating a query for a SQL database. Here is my query:
StartGesprek looks like '2018-07-11 15:54:40'
query="SELECT StartGesprek FROM dbo.tbl WHERE StartGesprek[:4]='2018'"
as you can see I want to select just the first 4 characters from StartGesprek but I get an error:
pyodbc.ProgrammingError: ('42000', "[42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near ':4'. (102)
I can not find anything on Google (or I'm not looking for the right thing.
I hope you bright boys and girls know the answer.
I've got a question. I'm creating a query for a SQL database. Here is my query:
StartGesprek looks like '2018-07-11 15:54:40'
query="SELECT StartGesprek FROM dbo.tbl WHERE StartGesprek[:4]='2018'"
as you can see I want to select just the first 4 characters from StartGesprek but I get an error:
pyodbc.ProgrammingError: ('42000', "[42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near ':4'. (102)
I can not find anything on Google (or I'm not looking for the right thing.
I hope you bright boys and girls know the answer.