Solved

summing timevalues query faulty

Posted on 2013-12-09
7
224 Views
Last Modified: 2013-12-16
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)
0
Comment
Question by:developingprogrammer
7 Comments
 
LVL 26

Assisted Solution

by:Shaun Kline
Shaun Kline earned 125 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 35

Assisted Solution

by:PatHartman
PatHartman earned 125 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 39

Assisted Solution

by:als315
als315 earned 125 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 49

Accepted Solution

by:
Gustav Brock earned 125 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))
  ' 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

/gustav
0
 

Author Comment

by:developingprogrammer
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 49

Expert Comment

by:Gustav Brock
ID: 39721009
You are welcome!

/gustav
0
 

Author Comment

by:developingprogrammer
ID: 39721010
= ))
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question