I have a record-set like this that contains unix timestamps to record dates:
+----+-----------+-----------+---------+
|Id |Start Date |EndDate |MoreData |
+----+-----------+-----------+---------+
|1 |1292692439 |2147483647 |... |
+----+-----------+-----------+---------+
|2 |1272776400 |1274331600 |... |
+----+-----------+-----------+---------+
|3 |1293256800 |2147483647 |... |
+----+-----------+-----------+---------+
|4 |1294552800 |2147483647 |... |
+----+-----------+-----------+---------+
What i need to do is write a MySQL query (using PHP) that only returns the rows that contain the startdate that is in or before this month and the enddate is in or after this month.
For example, in the above record-set, if querying for this month (December 2010) the rows with id 2 and 4 should not be returned because 2’s enddate is in May 2010 and 4’s startdate is in January 2011.
Help with how the query might look is greatly appreciated or any ideas with what MySQL query commands might come in useful when writing this query?
I actually used this format to test dates:
Which was the easiest and most simple to implement. It was suggested by Thrustmaster in the comments.