By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,863 Members | 838 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,863 IT Pros & Developers. It's quick & easy.

Filter records between range of dates

P: 1
15 DOCTORS NAME IN DATABASE, 2ND FIELD ON_LEAVE_FROM(DATE) 3RD FIELD TO_LEAVE(DATE)
NOW 3 DOCTORS ARE ON LEAVE ON DIFFERENT DATES E.G DOC1 ON LEAVE FROM 03 JUN TO 06 JUN 12, DOC2 FROM 05 JUN TO 15 JUN AND SO ON.
NOW HOW CAN I MAKE A QUERY TO RETRIEVE THE AVAILABILITY OF DOCTORS IN RANGE OF DATES e.g AVAILABILITY FROM 01/6/12 TO 10/06/12)
Jun 7 '12 #1
Share this Question
Share on Google+
1 Reply


Rabbit
Expert Mod 10K+
P: 12,357
Left join the doctor's table to the leave table where the leave start date is before the range end date and the leave end date is after the range start date. This will return those that don't have an overlapping leave and those that do. To remove those that do, choose only the ones where the right table's key is null.
Jun 7 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.