Convoluted title. I am using python sqlalchemy with a postgresql database.
I have a database that stores Events
, and each event record has a starttime
and a endtime
column. Both of the aforementioned columns are in this format:
2015-06-22 13:00:00
How can I therefore query the database for all Events
from a specific day. Thereby ignoring the "time" part of the starttime
and endtime
columns?
For example I tried:
query = Event.query.filter(Event.starttime=='2015-06-22', Event.endtime=='2015-06-22').all()
However this came up with 0 results, I am assuming perhaps this is because the absence of hh/mm/ss makes the query 'assume' that I mean 00:00:00.
I also tried
query = Event.query.filter(Event.starttime>='2015-06-22', Event.endtime<='2015-06-22').all()
But this came up with 0 results as well, I assume for the same reason as the previous.
Any help would be appreciated!
This is the query that gets sent to the DB:
SELECT events.id AS events_id, events.summary AS events_summary, events.starttime AS events_starttime, events.endtime AS events_endtime, events.parentcal AS events_parentcal, events.userid AS events_userid
FROM events
WHERE events.starttime >= :starttime_1 AND events.endtime < :endtime_1