Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please help me to get an SQL in access

Status
Not open for further replies.

jancypaul

Programmer
Aug 3, 2007
20
GB
Dear All expertise please help me



The following is the table structure of Holiday table

EmployeeID(Integer)
HolidayFrom(date)
HolidayTo(date)



The following record exist in the table



EmployeeId HolidayFrfom Holidayto

------------------------------------------
5 25/12/2007 28/12/2007

1 02/01/2008 10/01/2008

2 03/01/2008 03/01/2008

3 25/01/2008 27/01/2008





I want a report to get the employee who did take the leave from the given date range. For example I am giving the date range as follows



date from 03/01/2008

Date to 04/01/2008



When I given the date range as above two record have to be displayed . Because Employee 1 and 2 will be on leave on that date.

EmployeeId HolidayFrfom Holidayto

------------------------------------------

1 02/01/2008 10/01/2008

2 03/01/2008 03/01/2008





So please help me to find out an SQL to display the records from the given criteria of two date range

 




Hi,

Here's a view of the possibilities...
[tt]
Dates that do not quallify
Holidayto HolidayFrom
| |

| |
DateFrom DateTo
[/tt]
Code:
Where Holidayto < DateFrom OR DateTo < HolidayFrom


Skip,
[sub]
[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue][/sub]
 
SELECT EmployeeId, HolidayFrom, HolidayTo
FROM [Holiday table]
WHERE HolidayFrom <= [date to] AND HolidayTo >= [date from]

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 




yes AND [blush]

Skip,
[sub]
[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top