-5

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?

The Humble Rat
  • 4,586
  • 6
  • 39
  • 73
Tim Hanssen
  • 167
  • 1
  • 1
  • 9
  • Did you research this at all perhaps try the mysql docs or even google mysql select between dates ? Go do some research and try it first then if you fail come back and ask questions – Dave Mar 26 '14 at 10:56
  • [This link](http://stackoverflow.com/questions/1080207/mysql-select-all-data-between-two-dates) could give you some idea. – Vagabond Mar 26 '14 at 10:59

2 Answers2

0

like this:

SELECT * FROM events WHERE CURRENT_DATE BETWEEN cmde_edate_start AND cmde_edate_end
jmail
  • 5,944
  • 3
  • 21
  • 35
  • hey jmail, thanks for you'r reply. I need to select a range with two dates. So alle events happing betweem date A and B. – Tim Hanssen Mar 26 '14 at 12:08
  • what you want, i can't understand,.. you should that much of information only show.. – jmail Mar 26 '14 at 12:15
0

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.

The Humble Rat
  • 4,586
  • 6
  • 39
  • 73
  • Thanks for your reply. But in this case a event starting on 2014-02-03 until 2014-02-15 wont show up if i need to get events from 2014-02-01 until 2014-03-03 – Tim Hanssen Mar 26 '14 at 12:06