Solved

DateDiff function pulling wrong time duration

Posted on 2008-10-26
4
320 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
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.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

746 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

8 Experts available now in Live!

Get 1:1 Help Now