Results 1 to 8 of 8
  1. #1
    Nuke1096 is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Apr 2013
    Posts
    53

    Summing Time is giving me wrong totals.

    Ok, I'm stumped on this one. I'm trying to create a query that will sum the total time of a specific field. It seems to be doing it, however the value is off by by a couple minutes on all my examples and I cant seem to figure out why. Let me break it down how I'm doing it...



    Table

    - BusArrivalTime
    - BusDepartTime



    Query


    In my Query I'm making a new field like this. It correctly figures out the difference.

    BusWaitTime: DateDiff("n",[BusArrivalTime],[BusDepartTime])



    Report

    Next I'm displaying that Query information inside of a Report by putting this in the Text Box on the Report. It correctly displays the time in the Hours/Minutes format.

    =[BusWaitTime]\60 & Format([BusWaitTime] Mod 60,"\:00")


    Lastly, I'm using another Text Box on the Report to Sum the Grand Total of the Wait Time for all my records. Here is what Im putting in the Control Source

    =Sum([BusWaitTime])\60 & Format([BusWaitTime] Mod 60,"\:00")

    ...and it's summing my records, but the value is off by a few minutes and I cant figure out why.


    In my example, I have 3 records with times of 3:14, 1:35, and 3:20. It should be totaling a figure of 8:09 but its coming to 8:14 instead. Any suggestions?

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,523
    You're summing in the hours but not in the minutes. It's likely using the last record's minutes.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Nuke1096 is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Apr 2013
    Posts
    53
    Wouldnt it come out as 7:14 instead of 8:14 in that case? In any event though, how would I sum the minutes into that syntax, alongside the hours?

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,523
    Wrap the field in the Sum() function just as you did in the hours calculation.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Nuke1096 is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Apr 2013
    Posts
    53
    I tried doing that by doing...

    =Sum(Hour([BusWaitTime])+Minute([BusWaitTime]))

    ...but it's now just giving me 0 as a sum.

  6. #6
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,523
    =Sum([BusWaitTime])\60 & Format(Sum([BusWaitTime]) Mod 60,"\:00")
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    Nuke1096 is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Apr 2013
    Posts
    53
    Ohhh ok I see now. Yup that did it! I hate working with Time/Dates!!!!

    Thanks a ton!

  8. #8
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,523
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Summing Sum totals
    By Jamescdawson in forum Access
    Replies: 3
    Last Post: 11-22-2012, 03:11 PM
  2. Calculation in Query giving wrong results
    By dargo72 in forum Queries
    Replies: 11
    Last Post: 11-07-2012, 05:39 AM
  3. Access giving wrong result using sql query
    By amlanroy in forum Access
    Replies: 3
    Last Post: 05-10-2012, 10:11 AM
  4. Title: Giving Wrong Name
    By netchie in forum Forms
    Replies: 5
    Last Post: 09-15-2011, 10:53 AM
  5. Summing totals in reports
    By Harley Guy in forum Reports
    Replies: 4
    Last Post: 04-06-2010, 08:53 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