Hello all,
I apologize if this has been discussed before, I searched the forum and didn't find anything relevant. I've narrowed down the problem to my MySQL SELECT statement. I haven't even tried this in PHP yet, this is still on the MySQL CLI. First some basic info:
Mysql 4.1.11 Standard
PHP 4.3.2-19
I'm writing a scheduling application for some of our employees. I'm currently stuck in a section of code that checks a range of days to see whether or not a particular employee is already scheduled. Relevant columns are listed below:
TABLE JOB_DETAIL
START_DATE date
END_DATE date
EMPLOYEE_1 int(11) unsigned
EMPLOYEE_1 is an int that I join to another table with more employee detail. I have an example job in the database with a START_DATE of '2005-05-08' and an END_DATE of '2005-05-12'.
My SELECT statement is as follows:
SELECT * FROM JOB_DETAIL WHERE START_DATE >= '2005-05-08' and END_DATE <= '2005-05-09' AND EMPLOYEE_1 = 1;
and I will always get "0 rows returned".
This is an example query if I were trying to schedule an employee for a job and he was already scheduled (for May 5th through the 12th, my example data). In my mind this should return the example job listed in the database. In my PHP code this would return a row and I would flag it as a conflict.
MySQL doesn't seem to really support the >= and <= when operating on dates. I've tried using 20050508 and variations but it still doesn't seem to be working. Does anyone know of a workaround to this problem? I tried using UNIX_TIMESTAMP, but I can't figure out how to get the START_DATE and END_DATE columns into the UNIX_TIMESTAMP function. Any ideas?
Thanks,
Eric