0

I am facing an error while running a SQL query.

The error I am receiving is:

(102, b"Incorrect syntax near '2020-01-31 00:00:00'.DB-Lib error message 102, severity 15:\nGeneral SQL Server error: Check messages from the SQL Server\nDB-Lib error message 102, severity 15:\nGeneral SQL Server error: Check messages from the SQL Server\nDB-Lib error message 102, severity 15:\nGeneral SQL Server error: Check messages from the SQL Server\n")

Since the query is lengthy, I am putting only part of the query where the error is being shown:

T1.submit_date < ts '2020-01-31 00:00:00'

If need be, I will edit and put the entire query.

Any help is appreciated.

Thank you.

6
  • what is ts here ? Commented Feb 7, 2020 at 8:05
  • This is SQL Server (Microsoft SQL, MS SQL) error message, not MySQL message. Compare one more time letter-by-letter: MS SQL and MySQL. Commented Feb 7, 2020 at 8:34
  • Hi Red. ts is timestamp, an ODBC literal escape sequence. More information here: stackoverflow.com/questions/15759458/… Commented Feb 7, 2020 at 9:06
  • Hi Akina. It is MySQL that I am using in the backend. I am unclear on a thing. Are you suggesting that I should change the title of my question and the tags? I think the server is throwing an error because of something wrong in the query. Commented Feb 7, 2020 at 9:07
  • 1
    Oh really sorry guys. I am new to databases and didn't know that these two are two different technologies themselves. { insert embarrassed emoji here } Commented Feb 7, 2020 at 10:50

1 Answer 1

2

This is not the correct format for ODBC escape sequences. It should be wrapped in {}

where T1.submit_date < {ts '2020-01-31 00:00:00'}
Sign up to request clarification or add additional context in comments.

2 Comments

Upon changing the code to this, I get another error: Keyerror at "ts '2020-01-31 00"
That isn't a database error. Probably you need this stackoverflow.com/questions/5466451/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.