Results 1 to 10 of 10
  1. #1
    newtoAccess is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Nov 2009
    Posts
    226

    Smile Can hours be sum?

    I am new To MS Access.



    I am trying to total hours worked for the week.

    Problem1: group by employee, and sum the hours for each employee per day.

    The fields are StartTime, EndTime, HrsWrkDay, hrsWrkweek, the format is 00:00

    I have the grouping done but the sum of the hours are not correct.
    So can I sum time? or do I have to convert the daily time total to something else and then sum the daily?

    If so How
    NewToAccess

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,597
    You must calculate the elapsed time (DateDiff function) then sum the results.

    All four fields are Date/Time fields?

    If elapsed period crosses midnight, need to include date part in the calculated values.
    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.

  3. #3
    newtoAccess is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Nov 2009
    Posts
    226
    I do not under stand the help secton on this "DateDiff"?
    DateDiff(interval, date1, date2 [, firstdayofweek] [, firstweekofyear] )
    I am not sure where to put it?

    I did this in a Query and it dissappeared
    Dif_Date_test: DateDiff(1, SundayStartofweek, SaturdayEnd of week, , )

    What am I doing wrong

  4. #4
    newtoAccess is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Nov 2009
    Posts
    226
    SELECT Hours_Worked.employee, Hours_Worked.[Complete date], Hours_Worked.StartTime, Hours_Worked.EndTime, Hours_Worked.TotalHours, Hours_Worked.TotalHours AS hrs_Dec, ([TotalHours]/1000) AS EmployeeHrs, DateDiff(1,[StartTime],[EndTime],0) AS date_Test
    FROM Hours_Worked
    WHERE (((Hours_Worked.[Complete date])>=[Forms]![Select_Wrk_Week]![StartofWeek] And (Hours_Worked.[Complete date])<=[Forms]![Select_Wrk_Week]![EndofWrkWeek]))
    ORDER BY Hours_Worked.employee;

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,597
    So this is working? Issue solved?
    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.

  6. #6
    newtoAccess is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Nov 2009
    Posts
    226
    No it is not.

    I need to "group by" employee name and have the group sum the hours worked for the week for each individule employee.
    Any suggestions on how to do this?

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,597
    Build an Access report with Grouping & Sorting and aggregate calcs. Use the query you show as the RecordSource for the report. This is basic Access functionality and Access Help has guidelines.
    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.

  8. #8
    newtoAccess is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Nov 2009
    Posts
    226
    Can i use the results in the report for a different query?

  9. #9
    newtoAccess is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Nov 2009
    Posts
    226

    how do I see the results?

    When I go to create a new query I do not see the report.
    I need the results so I can do some other stuff.

    How do I get the results so I can do other calculation?

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,597
    A query would be used as the RecordSource for a project. No, any calcs done with report Grouping and Sorting and aggregate calcs in headers/footers would not be available for use elsewhere.

    To do summary calcs in query must do a Totals query. This will include a GROUP BY clause. Again, look at Access Help for guidelines on Totals (summary, aggregate) queries. Or review this http://office.microsoft.com/en-us/ac...010096310.aspx
    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. Hours and OT Hours
    By Ruthers456 in forum Forms
    Replies: 2
    Last Post: 06-27-2011, 10:09 AM
  2. Sum hours worked, grouped by dep't
    By goodfood in forum Queries
    Replies: 3
    Last Post: 05-05-2011, 06:11 AM
  3. workinkg hours by percent
    By Mosely in forum Queries
    Replies: 1
    Last Post: 11-01-2010, 09:32 AM
  4. Grouping hours query
    By DMP84 in forum Queries
    Replies: 0
    Last Post: 08-26-2010, 07:15 AM
  5. hours + condition
    By Miriam in forum Queries
    Replies: 0
    Last Post: 08-09-2009, 06:46 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