Query to select records not present on a particular date between two given dates

  • I have a employee attendance table with columns Empid, AttendanceDate, Hoursclocked.

    Now I want to list all the employees who were not marked their hours between the given two dates. For example I will input 01-09-2008 and 30-09-2008, I should able to get the list employee records that is not present in this employee attendance table.

    Thanks is Advance

    Sathish

  • You would obtain better help if you followed the procedures recommended in the article in my signature block.

    Now assuming that the attendance table includes

    A row for each employee, for each working day the AttendanceDate is entered as a date with the time portion defaulted ("1/9/2008 12:00:00 AM") and that the hoursclocked column in your table allows NULL then the following would be adequate

    SELECT empid, hours FROM Attendance WHERE AttendanceDate BETWEEN '09-01-2008' AND '09-30-2008' AND Hoursclocked IS NULL

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • If you just want employees that have no hours logged in the time frame then bitbuckets solution will work, but if you want a list of dates when an employee logged no hours then you would need a different solution that would work best if you have a dates table. For example employee A only logged hours on 17-09-2008 so you would get all the other dates for employee A.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply