HI
I have a stored Procedure listed below
I want to select records from attendance Table joined on employee if record for some employee is missing then select them as absant it works fine for single date but when i change Where clause to between dates it select only few records that are present in AttendanceRecords table
Please Help me
alter proc att_AttendanceReport
@Date1 datetime =NULL,
@Date2 datetime =NULL
AS
if @Date1 IS NULL
Select @Date1=GETDATE()
If @Date2 IS NULL
Set @Date2=Getdate()
Select CONVERT(VARCHAR(11),(isnull(ar.RecordDate,GETDATE())),120) AS 'Record Date',E.EmployeeNumber,e.EmployeeName,ar.Arrival,ar.Departure, s.StatusName from Employees e
left outer join EmployeeAttendanceRecords ar on ar.employeeid=e.EmployeeID
inner join AttendanceStatus s on isnull(ar.AttendanceStatusID,2)=s.StatusID
where RecordDate between @Date1 AND @Date2 OR RecordDate IS NULL
Rashed