Solved

DateDiff function pulling wrong time duration

Posted on 2008-10-26
4
321 Views
Last Modified: 2013-11-27
In my query Im attempting to calculate the exact time duration from clockin to clockout

I'm using this function to calculate the Duration field:
Duration: DateDiff("h"[clock_in_datetime],[clock_out_datetime])

The output for this is round numbers.  Is this avoidable?  I need the increments as well.

Clock_In_Datetime         Clock_Out_Datetime      Duration
9/3/2008 2:25:00 PM       9/3/2008 7:27:00 PM     5.00
9/3/2008 5:00:00 PM       9/3/2008 7:39:00 PM      2.0                                                                                
9/3/2008 5:03:00 PM       9/3/2008 8:22:00 PM      3.00
9/3/2008 5:13:00 PM       9/3/2008 8:27:00 PM      3.00
9/3/2008 6:35:00 PM       9/3/2008 10:14:00 PM    4.00                          
9/3/2008 8:11:00 PM       9/4/2008 1:34:00 AM      5.00

thanks



0
Comment
Question by:Cole100
  • 2
4 Comments
 
LVL 46

Expert Comment

by:tbsgadi
ID: 22806543
Hi Cole100,

You can use minutes "n"
http://www.techonthenet.com/access/functions/date/datediff.php

Good Luck!

Gary
0
 
LVL 22

Accepted Solution

by:
dportas earned 200 total points
ID: 22806549
DATEDIFF counts the number of time "ticks" between the two times in whatever sized units you specify. So if you want to be more precise you could select the units to be minutes or seconds and then divide the result by 60 or 3600.
0
 

Author Comment

by:Cole100
ID: 22806550
Using "n" gets total minutes.  I need hours rounded to the .1

clockin      clockout     duration (hrs)
4:00pm      8:30pm           4.5

thank you.

0
 

Author Comment

by:Cole100
ID: 22806557
dportas:

I should have caught that.  Thanks very much.  That got it.

0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

896 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now