Results 1 to 4 of 4
  1. #1
    markgoodridge is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    May 2017
    Posts
    2

    Create a Headcount Access query based on dates

    Hi All,



    I am trying to create what I thought would be an easy access query.

    I'm trying to determine the number of staff working for my organisation as at today's date, based upon their assignment start date and assignment end date. So if an employee is in post as at today, it will return a 1 and if not a zero, which I would then like to total up.

    The main table that I believe should be used is listed out below:

    AssignmentID(PK)
    StaffName
    RoleTitle
    CurrentFTE
    AssignmentStart (date)
    AssignmentEnd (date)

    Ideally, I would like to know how to build a formula using design view, rather than SQL.

    Any assistance would be gratefully received.

    Many, many thanks in advance.

    Mark

  2. #2
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Is the AssignmentEnd field always populated?

    If so, then try this formula:
    Code:
    IIf(([AssignmentStart]<=Date()) And ([AssignmentEnd]>=Date()),1,0)
    Note that you can also get your count in a query without any formulas by doing an Aggregate Count Query, using Criteria.

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    Don't use SQL, use a query. Similar to :
    Select count(staffname) from table where startDate <= date and EndDate >= date

  4. #4
    markgoodridge is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    May 2017
    Posts
    2
    Hi Joe,
    Yes the "assignmentend" field is a contracted end date of 31/03/20, although could be different if the employee has already left

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 04-20-2016, 03:41 AM
  2. Replies: 2
    Last Post: 02-23-2016, 04:36 PM
  3. Replies: 7
    Last Post: 07-11-2013, 10:45 AM
  4. Query based on dates ish
    By BigMac4 in forum Queries
    Replies: 4
    Last Post: 08-25-2012, 10:05 AM
  5. Replies: 0
    Last Post: 02-27-2009, 01:39 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums