Reputation: 79
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.
Upvotes: 0
Views: 133
Reputation: 42611
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")
Upvotes: 2