I have a SQLite database with a datetime column like below and I do query using Python(import sqlite3):
First of all, the following query is successful:
sqlite_select_query = 'SELECT DateTime FROM myTable WHERE DateTime BETWEEN "2022-03-14 14:09:08" and "2022-03-15 17:04:51"'
But I want to make start and end dates user selectable and write the query in the following form:
startingDate = "2022-03-14 14:09:08"
endingDate = "2022-03-15 17:04:51"
sqlite_select_query = 'SELECT DateTime FROM myTable WHERE DateTime BETWEEN '+startingDate+' and '+endingDate+'
But the above give the following error:
SyntaxError: EOL while scanning string literal
startingDate = "2022-03-14 14:09:08"
endingDate = "2022-03-15 17:04:51"
Then I tried to add one more ' at the end as follows:
sqlite_select_query = 'SELECT DateTime FROM myTable WHERE DateTime BETWEEN '+startingDate+' and '+endingDate+''
But now the above doesn't select anything.