Results 1 to 8 of 8
  1. #1
    Join Date
    Jul 2004
    Posts
    156

    Unanswered: Employees Hire/Fire Dates

    Hello ghouls and ghosts:

    Has anyone out there had experience in sorting out employees based on their hire and termination dates? My interests lie in going further than just filtering out employees with certain hire/term dates. What I need to do is for a given date range, have salaried employees either factored in or not based on whether they were working during all OR part of the date range. Do you understand what I'm asking? Maybe an example will help.

    For a:
    Facility Production Labor Cost - Salaried Report
    SalariedEmployee1 Hired 1/1/04 Term: None
    SalariedEmployee2 Hired 11/12/03 Term: 1/1/04
    Salaried Employee3 Hired 2/2/04 Term: None
    for the dates 12/1/03 - 6/1/04

    A query would just figure up their annual salary, divide it by 365 and multiply it by the days they were working during the defined dates, 12/1/03 - 6/1/04. What I don't know how to handle is figuring out how many days they were actually employed between the dates 12/1/03 and 6/1/04. Employee1 will have only worked from 1/1 to 6/1. #2 goes from 12/1/03 to 1/1/04. #3 only goes from 2/2/04 to 6/1/04.

    See my dilemma? I'm sure this isn't too easy of a task to tackle, but I don't know really where to start. But it seems as though this would be a common problem. Any suggestions would be GREATLY appreciated. Thanks!
    DocX

    The teachings of God's Begotten: 2 John 1:9

  2. #2
    Join Date
    Sep 2004
    Location
    Charlotte, NC
    Posts
    164
    This assumes there is a table called 'Salaried' with fields for 'Employee', 'HireDate', TerminateDate', and 'Salary'.

    SELECT Salaried.Employee, IIf([terminatedate]<[Range_Start_Date],"N",IIf([hiredate]>[Range_End_Date],"N","Y")) AS Include, IIf([hiredate]<[Range_Start_Date],[range_start_date],[hiredate]) AS FromDate, IIf([terminatedate] Is Null,[range_end_date],IIf([terminatedate]>[Range_End_Date],[range_end_date],[terminatedate])) AS ToDate, round((CDate([todate])-CDate([fromdate])+1)*[salary]/365,2) AS SalaryPaid
    FROM Salaried
    WHERE (((IIf([terminatedate]<[Range_Start_Date],"N",IIf([hiredate]>[Range_End_Date],"N","Y")))="Y"));

    When this is run, you will be asked to enter 2 parameters; 'Range_Start_Date' and 'Range_End_Date', which in your example are 12/01/03 and 6/01/04.

    Hope this helps.
    TD

    "Conscience is the inner voice, which warns us that someone may be looking." - Henry Louis Mencken

  3. #3
    Join Date
    Jul 2004
    Posts
    156
    What is the CDate function? I couldn't find it in Access's help or VBA's.
    DocX

    The teachings of God's Begotten: 2 John 1:9

  4. #4
    Join Date
    Jul 2004
    Posts
    156
    Another question is: is there a reason for putting the Include field in the Select statement if you're only going to be using it as criteria?
    DocX

    The teachings of God's Begotten: 2 John 1:9

  5. #5
    Join Date
    Sep 2004
    Location
    Charlotte, NC
    Posts
    164
    The CDate function converts a valid date and time expression to the variant of subtype Date, and returns the result.

    On your second question, you are right about not needing the Include field. I originally set this up as a select query and created the Include field so I could use it for the select logic and was just checking to make sure the logic was working, but I should have unchecked the field prior to converting to SQL. My mistake. You can leave it out since it is not necessary.

  6. #6
    Join Date
    Jul 2004
    Posts
    156
    I have another question for you that goes along with labor cost. I also have to figure up the cost of those employees who are hourly. I haven't quite figured out the structure yet of how to do this. The primary difficulty is the fact that their wages can change. If a report is generated after a wage change but is based on work that was done before the wage change then the labor cost will be erroneous.

    I have thought about a table holding the employee number, the date of the wage change and the new wages. The problem with this is simplicity. Designing a query that will divide the date range into chunks based on the wage change dates and figure out the corresponding labor cost for that chunk and THEN sum them together seems like a rather large, complicated task.

    Even though it would break normalization, I have thought of placing in the labor hours table two fields for regular payrate and overtime payrate which would be copied over from the EmployeeInfo table which holds these values. That way it would have an accurate payrate for those labor hours on that date. I hope I'm making sense with my explanation here.

    I don't believe the second option would cause a disproportionate increase in database size by adding two integer values, which is bigger than only byte values, per each record. Plus, with deadlines approaching, the quicker way is the better way at the moment.

    But I would appreciate your suggestions.
    DocX

    The teachings of God's Begotten: 2 John 1:9

  7. #7
    Join Date
    Jul 2004
    Posts
    156
    Anyone have suggestions?
    DocX

    The teachings of God's Begotten: 2 John 1:9

  8. #8
    Join Date
    Jul 2004
    Posts
    156
    TD (or anyone):

    In your example that you gave, what if there is no term date for the pure reason that the person hasn't been terminated? Does this code still work? I'm thinking it wouldn't know how to handle a date being compared to a null/empty string. I guess that it could be handled in the end date function. Got a suggestion?
    DocX

    The teachings of God's Begotten: 2 John 1:9

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •