Hi, I have an application that keeps track of clock in and clock out times for employees. The application is written in PHP/MySQL, and the client side is HTML/PHP/Javascript on a website. When an employee clocks in an entry is created on the "timesheet" table.The entry includes an entry id, the employee id, date, time clocked in and then the entry is updated using the UPDATE command when an employee clocks out.I am now trying to design a tool that allows the employer to search the database for a specific employee's clock in and clock out times between two dates ($from_date, $to_date).The query i am using is: $sql = "SELECT employees.id, employees.firstname, employees.lastname, timesheet.date, timesheet.time_in, timesheet.time_out FROM employees INNER JOIN timesheet ON employees.id = timesheet.employeeid WHERE employeeid = '$employee_id' AND timesheet.date BETWEEN '$from_date' AND '$to_date' ORDER BY timesheet.date ASC";
I also tried:$sql = "SELECT employees.id, employees.firstname, employees.lastname, timesheet.date, timesheet.time_in, timesheet.time_out FROM employees INNER JOIN timesheet ON employees.id = timesheet.employeeid WHERE employeeid = '$employee_id' AND timesheet.date >= '$from_date' AND timesheet.date <= '$to_date' ORDER BY timesheet.date ASC";
The results i get are always missing the first entry of the range. I understand that the BETWEEN operator is inclusive, which should be the reason the above is happening. I tested using the >= and <= operators and the results did not change. There has to be a way to have the query include the first date in the range...or is there?Any input is appreciated. Thanks in advance.TSiqueira