Results 1 to 2 of 2
  1. #1
    Futtecr is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    5

    Cumulative data in a query where there may be more than one row for each person.


    While I am not new to databases I am relatively new to Acces (using 2010). In a daughter table which is the "many" of a 1 to many relationship, I want to calculate TOTAL amount of time. There is a start date/time and an end date/time. That part is easy. There may be 1 or more than one record for each patient. I want the total time. So if the first occurance (record) was 2 days and the 2nd occurance (another record) was 1 day the total would be 3 days. In this table there are many patients. Can I do this in a query?
    The fields I would use are the caseID, StartDate, StartTime, EndDate, EndTime. (I did not design this table)

    Thanks in advance,

    Craig

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Use DateDiff function in query to calculate the elapsed days. Then build a report with that query as RecordSource. Build a group on the patient ID. In group footer textbox, calculate total days with Sum function. Example query:

    SELECT *, DateDiff("d",StartDate,EndDa5t) + 1 As Days FROM tablename;

    If you have to account for partial days by use of the Start and End times, that gets a bit more complicated, especially with the data and time parts in separate fields.
    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.

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

Similar Threads

  1. Attendance Log - Missing person(s) Query
    By hinoks in forum Access
    Replies: 6
    Last Post: 02-15-2012, 12:11 PM
  2. Looking for Person who can create data base
    By nemolist in forum Database Design
    Replies: 3
    Last Post: 02-02-2012, 01:42 PM
  3. Replies: 1
    Last Post: 08-25-2011, 09:50 AM
  4. Cumulative total in query
    By MikeWaring in forum Queries
    Replies: 2
    Last Post: 12-18-2010, 01:40 PM
  5. cumulative rainfall query
    By wilkesgra in forum Queries
    Replies: 5
    Last Post: 09-29-2010, 07:27 AM

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