Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Skydolphin
Starting Member
43 Posts |
Posted - 2007-10-10 : 19:28:25
|
| Hi all,I am building a report for our HR department that queries employees approved leave requests. What they want is to be able to enter a date range and find all the people who were absent during that time period.select username,fullname,email,begindate,enddate,region,employeecomments,leavetype,approvername,approveremail,approval,approvaldate,approvercommentsfrom tblLeaveRequestwhere Fullname IS NOT NULL AND Fullname <> '' AND Email IS NOT NULL AND BeginDate IS NOT NULL AND EndDate IS NOT NULL and approval = 'Approved' and region = @Region and begindate >= @BeginDate and enddate < @EndDateorder by Username, BeginDategiven the sample data:Jane Doe took vacation from 10/23/2006 thru 10/30/20061) if the date range entered is exactly that it returns Janes data 2) if the date range entered is 10/25/2006 thru 10/30/2006 Jane's data is not returned even though she was on vacation during that time. I have no idea how to write this query. FYI the date fields are actually defined as datetime fields.Any help would be greatly appreciated. It's probably simple but I just can't see it.Thanks,Rhonda |
|
|
Zoroaster
Aged Yak Warrior
702 Posts |
Posted - 2007-10-10 : 20:27:49
|
Please provide sample data. Future guru in the making. |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-10-11 : 00:34:46
|
| WHERE begindate <= @EndDate and enddate >= @BeginDateKristen |
 |
|
|
|
|
|
|
|