Page 1 of 1

help with sql query

Posted: Fri Feb 13, 2009 1:46 am
by greedyisg00d
I have a schedule table and it has 3 fields(emp_name,date_from,date_to). This is my scenario, for example the employee greedyisgood is set for a trip from 2009-02-04 up to 2009-02-08 . (YYYY-MM-DD)

date_from = 2009-02-04
date_to = 2009-02-08

Thus when the secretary inputs a specific date 2009-02-06 via textbox for the meeting, the employee greedyisgood will not be shown on the list since the date specified is in between 2009-02-04 up to 2009-02-08. Any idea on how will be the query?

Thanks

Re: help with sql query

Posted: Fri Feb 13, 2009 3:56 am
by Salaria
greedyisg00d wrote:I have a schedule table and it has 3 fields(emp_name,date_from,date_to). This is my scenario, for example the employee greedyisgood is set for a trip from 2009-02-04 up to 2009-02-08 . (YYYY-MM-DD)

date_from = 2009-02-04
date_to = 2009-02-08

Thus when the secretary inputs a specific date 2009-02-06 via textbox for the meeting, the employee greedyisgood will not be shown on the list since the date specified is in between 2009-02-04 up to 2009-02-08. Any idea on how will be the query?

Thanks
You can create a query like "SELECT emp_name FROM schedule WHERE date_from < specified_date OR date_to > specified_date;"

It will show only those employees who are not on trip as per your schedule.

Best Regards,
Mahesh Salaria