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

Peder Ward :

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

Akina :

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")

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=194854&siteId=1