Pick out rows between two dates that have the same time in SQL to Python

141 views Asked by At

I would like to import rows from mySQL database into Python. I would like to take out rows between two dates that have the same timstamp. I have managed to import between two dates with this line:

"SELECT * FROM table WHERE timestamp >= %s AND timestamp <=%s", (2020-03-07, 2020-03-10)

But I dont know how to spesific only rows where timestamp is for example 10:00:00. See picture for the database setup.

Database Database

1

There are 1 answers

0
Akina On BEST ANSWER

You need something like

"""
SELECT * 
FROM table 
WHERE timestamp >= %s 
  AND timestamp <=%s 
  AND DATE_FORMAT(timestamp, '%H:%i:%s' = %s)
""", ("2020-03-07", "2020-03-10", "10:00:00")