I need to select all events that are 'active' in a specifc time range.
This is how my table looks like
+---------------+------------------+----------------+
| cmde_eid | cmde_edate_start | cmde_edate_end |
+---------------+------------------+----------------+
I have two dates for this select, and I need to get all events that are active in the time range or a part of the time range.
Any suggestions?
like this:
SELECT * FROM events WHERE CURRENT_DATE BETWEEN cmde_edate_start AND cmde_edate_end
You could simply do:
SELECT *
FROM table name
WHERE cmde_edate_start > '0000-00-00' AND cmde_edate_end < '0000-00-00'
You could also use the MYSQL between
SELECT *
FROM table name
WHERE (cmde_edate_start BETWEEN '0000-00-00' AND '0000-00-00') AND (cmde_edate_end BETWEEN '0000-00-00' AND '0000-00-00')
http://www.w3schools.com/sql/sql_between.asp
You could even use a mix of the two. These are just two quick example of checking between dates.