summing timevalues query faulty

hi guys,

i've got a really strange result from adding timevalues together using a group by query. could yall help me take a look? the times from the group by sum is more than the individual records! thanks guys!!

this is normal querythis is normal query resultsthis is the group by SUM query that has a problemthis is the group by SUM query that has a problem (results)
Who is Participating?
Gustav BrockConnect With a Mentor CIOCommented:
Shaun is right. Your first query is wrong. It makes no sense to group by the total workhours as it will hide duplicate entries.

Your last query is correct except that it counts total work days, not hours. To get total hours in decimal, all you need is to multiply by 24.

To have a hour:minute display for hours exceeding one day, you need a function like this:
Public Function FormatHourMinute( _
  ByVal datTime As Date, _
  Optional ByVal strSeparator As String = ":") _
  As String
' Returns count of days, hours and minutes of datTime
' converted to hours and minutes as a formatted string
' with an optional choice of time separator.
' Example:
'   datTime: #10:03# + #20:01#
'   returns: 30:04
' 2005-02-05. Cactus Data ApS, CPH.

  Dim strHour       As String
  Dim strMinute     As String
  Dim strHourMinute As String
  strHour = CStr(Fix(datTime) * 24 + Hour(datTime))
  ' Add leading zero to minute count when needed.
  strMinute = Right("0" & CStr(Minute(datTime)), 2)
  strHourMinute = strHour & strSeparator & strMinute
  FormatHourMinute = strHourMinute
End Function

Open in new window

Shaun KlineConnect With a Mentor Lead Software EngineerCommented:
Your first query is grouping by the time difference. Are you sure that there are not multiple records that have the same time difference? Maybe add a count column to your first query to verify that each record is indeed only one.
PatHartmanConnect With a Mentor Commented:
Rather than subtracting one field from another, use the Datediff() function and specify minutes as the return unit.  Then divide that value by 60 to convert to hours.  The remainder is the minutes less than one hour.
The new generation of project management tools

With’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

als315Connect With a Mentor Commented:
It is normal result for time/date calculations. You should use special functions if you do not like to make conversions manually. Try datediff function:
result will be in minutes: first parameter -"n"
"s" - seconds
Sum values also in minutes
developingprogrammerAuthor Commented:
hey guys, thanks for all your help!

whilst i was trying out what yall were sharing with me, i realised inadvertently that the problem was with the text link file (though what yall said is very spot on too).

i realised that i can't change the link of a text linked file. i created another question here to ask that - "cannot change linked text file path"

gustav thanks for pointing out on how to capture hours and minutes exceeding one day - i definitely will be revisiting that moving forward! = )
Gustav BrockCIOCommented:
You are welcome!

developingprogrammerAuthor Commented:
= ))
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.