19
Knowing I have a table called eventos
, and this table has the columns id
, titulo
, inicio
and fim
. The columns inicio
and fim
are of the type timestamp, where the date and time of the start and end of a certain event is recorded. When making a select
in this table, how do I catch the events of a specific date between the column date beginning and the column end?
Example: Assuming I have a record in this table with the column beginning being of value 2014-02-01 13:00:00
and the column end with the value 2014-02-05 22:30:00
. It is an interval of 4 days, and their respective hours. How could I catch this record on a specific day using the following SQL below?
SELECT titulo
FROM eventos
WHERE inicio <= '2014-02-03'
AND fim >= '2014-02-03'
One of the problems is that if my record has the start column with value 2014-02-01 13:00:00
and I consult for WHERE inicio <= '2014-02-01'
, that is, same start date, is not found. Knowing that I have the operator <=
.
Perfect, that’s what it was :)
– paulomartinhago