Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# summing timevalues query faulty

Posted on 2013-12-09
Medium Priority
251 Views
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!!

0
Question by:developingprogrammer
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 27

Assisted Solution

Shaun Kline earned 500 total points
ID: 39706593
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.
0

LVL 39

Assisted Solution

PatHartman earned 500 total points
ID: 39706633
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.
0

LVL 40

Assisted Solution

als315 earned 500 total points
ID: 39706646
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:
DateDiff("n",[TimeIn],[TimeOut])
result will be in minutes: first parameter -"n"
"s" - seconds
Sum values also in minutes
0

LVL 51

Accepted Solution

Gustav Brock earned 500 total points
ID: 39707892
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))
strMinute = Right("0" & CStr(Minute(datTime)), 2)
strHourMinute = strHour & strSeparator & strMinute

FormatHourMinute = strHourMinute

End Function
``````
/gustav
0

Author Comment

ID: 39720997
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! = )
0

LVL 51

Expert Comment

ID: 39721009
You are welcome!

/gustav
0

Author Comment

ID: 39721010
= ))
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
###### Suggested Courses
Course of the Month10 days, 1 hour left to enroll