StealthRT
07-26-2008, 07:58 AM
Hey all i am trying to figure out a way to see if other employees are working the same type of hours that a user is. The time for all employees is formatted like this:
5:00 PM-10:00 PM
or
11:00 AM-4:30 PM
or
8:00 AM-3:00 PM
etc...
So lets say that a few employees work at 5 or after.. How can i check via mySQL to see if, out of the 100+ employees, that they work either at 5 or AFTER 5pm but also get off by 10pm? Of course i will already have the users time stored so that is what i can compare too agents all other employees.
So if the range is = or greater than 5pm but less or equal to 10pm.
How could i do this?? :confused:
Here is the code i am working on.....
$BeginningTime = strrpos($theMon, "-");
$BeginningTime = substr($theMon, 0, $BeginningTime);
//echo $BeginningTime . " ";
$EndingTime = strrpos($theMon, "-") + 1;
$EndingTime = substr($theMon, $EndingTime);
//echo $EndingTime;
$query = "SELECT * FROM `schedule" . $Monday . "` WHERE Mon >= '$BeginningTime' AND Mon <= '$EndingTime'";
BeginningTime looks like this: 5:00 PM
EndingTime looks like this: 10:00 PM
But it keeps returning 20 rows back.. some look corrected but others are WAYYYYY off.
Thanks for your time!
David
5:00 PM-10:00 PM
or
11:00 AM-4:30 PM
or
8:00 AM-3:00 PM
etc...
So lets say that a few employees work at 5 or after.. How can i check via mySQL to see if, out of the 100+ employees, that they work either at 5 or AFTER 5pm but also get off by 10pm? Of course i will already have the users time stored so that is what i can compare too agents all other employees.
So if the range is = or greater than 5pm but less or equal to 10pm.
How could i do this?? :confused:
Here is the code i am working on.....
$BeginningTime = strrpos($theMon, "-");
$BeginningTime = substr($theMon, 0, $BeginningTime);
//echo $BeginningTime . " ";
$EndingTime = strrpos($theMon, "-") + 1;
$EndingTime = substr($theMon, $EndingTime);
//echo $EndingTime;
$query = "SELECT * FROM `schedule" . $Monday . "` WHERE Mon >= '$BeginningTime' AND Mon <= '$EndingTime'";
BeginningTime looks like this: 5:00 PM
EndingTime looks like this: 10:00 PM
But it keeps returning 20 rows back.. some look corrected but others are WAYYYYY off.
Thanks for your time!
David