Hello everyone, help a newbie.

There is a MySQL table with EventID columns | Start | End

Start and End is a datetime type: the beginning and end of the event.

There is a date, for example the current one. What does a SQL query look like if you need to pull records that intersect with a certain date?

    1 answer 1

    This query will select entries in the date range of which the current date falls.

    SELECT * FROM table_name WHERE UNIX_TIMESTAMP(start) < UNIX_TIMESTAMP(NOW()) AND UNIX_TIMESTAMP(end) > UNIX_TIMESTAMP(NOW()) 
    • one
      @SiDquakers, then try with <= / >= - Byulent
    • Everything works fine. @SiD quakers be more attentive) - Vincent
    • Yes, I seem to be attentive -). @Vincent Sampling does not work if Start 2018-12-24 00:00:00 and End 2018-12-24 00:00:00 - SiD quakers
    • one
      why should it work if start = end? - Vincent
    • And in cases where a certain date, then what does the query look like? - SiD quakers