Results 1 to 5 of 5
  1. #1
    redhottsili is offline Novice
    Windows 8 Access 2013
    Join Date
    Sep 2015
    Posts
    2

    Modified Sum


    I have made an attendance table for workers which looks like this

    Click image for larger version. 

Name:	Attendance.PNG 
Views:	11 
Size:	18.1 KB 
ID:	22154

    Now I need a query which returns the sum of total days attended for each worker. However, there is a caveat. Normally, each worker can work only during weekdays, but if they show up 3 or more days in any given week they would get an extra day credited to them (as if they have also worked on Saturday).
    The sums are calculated for each month. So even if the first week of the month starts on a Friday, should the worker have showed up at least 3 days on that week, they will get the extra day on the current month.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    make your count query, qsCountDaysPerEmp, (select empID, count([AttendDate]) from table where [present] = true and dates between start and finish)

    now make another query using THAT query, that adds an Extra Day field and a TotalDays ,if the count>3
    (select *,iif([countOfDays]>3,1,0) as EarnedDay , [CountOfDays] +iif([countOfDays]>3,1,0) as TotalDays from qsCountDaysPerEmp)

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    you really dont need to store dates for a person if they are absent. then the dates owned by the emp are just counted.
    if the date doesnt exist, they were absent.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    I think ranman's suggestion is on the right track. The count query requires input of start and end dates for a single week. This means the query can consider only 1 week of data. If you need output for longer periods, the query will be more complicated.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    redhottsili is offline Novice
    Windows 8 Access 2013
    Join Date
    Sep 2015
    Posts
    2
    Alright, thank you for the input. I am going to try your suggestion and update.

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

Similar Threads

  1. Modified Universal Search
    By orange in forum Code Repository
    Replies: 4
    Last Post: 02-08-2017, 02:14 PM
  2. Last Modified with external edits
    By james28 in forum Macros
    Replies: 2
    Last Post: 04-30-2014, 06:21 PM
  3. Last Modified Record
    By drunkenneo in forum Programming
    Replies: 1
    Last Post: 01-06-2014, 10:58 PM
  4. modified Date & Modified BY
    By bronson_mech in forum Queries
    Replies: 1
    Last Post: 12-06-2013, 10:45 AM
  5. Modified Date
    By PatCollins in forum Import/Export Data
    Replies: 3
    Last Post: 04-24-2012, 01:13 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