I've got a bit of a problem calculating the duration of hours between
a clock-in time and a clock-out time. It's a fairly straight-forward
process. I put the clock-ins, clock-outs in a temp table and then do
an update on the table
UPDATE #TempEmpHours
SET Duration = DATEDIFF(mi, ClockIn, ClockOut)/60.0
The wacky results are below. Every other record has a negative value
for the duration. Has anybody ever seen something like this? Yes, I
am starting out with an empty temp table. I'm almost at my wit's
end. Any ideas?
Thanks,
Jennifer
ClockIn ClockOut Duration
8/23/08 3:00 PM 8/23/08 4:41 PM -18.2167
8/23/08 3:00 PM 8/23/08 6:02 PM 3.0333
8/23/08 3:00 PM 8/23/08 4:59 PM -17.9167
8/23/08 3:00 PM 8/23/08 7:20 PM 4.3333
8/23/08 3:00 PM 8/23/08 7:01 PM -15.8833 3 2481
So far the only thing I have figure out is that the negative are all
off by 1194 minutes. Very odd.
Roy Harvey
Beacon Falls, CT
On Fri, 26 Sep 2008 08:22:55 -0700 (PDT), Jennifer
<Sc**************@gmail.comwrote:
>I've got a bit of a problem calculating the duration of hours between a clock-in time and a clock-out time. It's a fairly straight-forward process. I put the clock-ins, clock-outs in a temp table and then do an update on the table
UPDATE #TempEmpHours SET Duration = DATEDIFF(mi, ClockIn, ClockOut)/60.0
The wacky results are below. Every other record has a negative value for the duration. Has anybody ever seen something like this? Yes, I am starting out with an empty temp table. I'm almost at my wit's end. Any ideas?
Thanks, Jennifer
ClockIn ClockOut Duration 8/23/08 3:00 PM 8/23/08 4:41 PM -18.2167 8/23/08 3:00 PM 8/23/08 6:02 PM 3.0333 8/23/08 3:00 PM 8/23/08 4:59 PM -17.9167 8/23/08 3:00 PM 8/23/08 7:20 PM 4.3333 8/23/08 3:00 PM 8/23/08 7:01 PM -15.8833
Exactly what version of SQL Server are you using? Exactly what
datatypes are ClockIn and ClockOut?
Roy Harvey
Beacon Falls, CT
On Fri, 26 Sep 2008 08:22:55 -0700 (PDT), Jennifer
<Sc**************@gmail.comwrote:
>I've got a bit of a problem calculating the duration of hours between a clock-in time and a clock-out time. It's a fairly straight-forward process. I put the clock-ins, clock-outs in a temp table and then do an update on the table
UPDATE #TempEmpHours SET Duration = DATEDIFF(mi, ClockIn, ClockOut)/60.0
The wacky results are below. Every other record has a negative value for the duration. Has anybody ever seen something like this? Yes, I am starting out with an empty temp table. I'm almost at my wit's end. Any ideas?
Thanks, Jennifer
ClockIn ClockOut Duration 8/23/08 3:00 PM 8/23/08 4:41 PM -18.2167 8/23/08 3:00 PM 8/23/08 6:02 PM 3.0333 8/23/08 3:00 PM 8/23/08 4:59 PM -17.9167 8/23/08 3:00 PM 8/23/08 7:20 PM 4.3333 8/23/08 3:00 PM 8/23/08 7:01 PM -15.8833
I think its the datatypes too. The results I receive below work fine
with your update statement in SQL Server 2005...
CREATE TABLE #TempEmpHours
(
ClockIn DATETIME,
ClockOut DATETIME,
Duration FLOAT
)
INSERT INTO #TempEmpHours (
ClockIn,
ClockOut
)
SELECT '8/23/08 3:00 PM', '8/23/08 4:41 PM'
UNION SELECT '8/23/08 3:00 PM', '8/23/08 6:02 PM'
UNION SELECT '8/23/08 3:00 PM', '8/23/08 4:59 PM'
UNION SELECT '8/23/08 3:00 PM', '8/23/08 7:20 PM'
UNION SELECT '8/23/08 3:00 PM', '8/23/08 7:01 PM'
UPDATE #TempEmpHours
SET Duration = DATEDIFF(mi, ClockIn, ClockOut)/60.0
SELECT * FROM #TempEmpHours
2008-08-23 15:00:00.000 2008-08-23 16:41:00.000 1.683333
2008-08-23 15:00:00.000 2008-08-23 16:59:00.000 1.983333
2008-08-23 15:00:00.000 2008-08-23 18:02:00.000 3.033333
2008-08-23 15:00:00.000 2008-08-23 19:01:00.000 4.016666
2008-08-23 15:00:00.000 2008-08-23 19:20:00.000 4.333333
-Eric Isaacs This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: inamori |
last post by:
I face that problems
07/01/2003 06/30/2006 ---------> it should be 3
01/01/2003 02/28/2005 --------->could i get 2 years and 2 months
01/01/2003 03/01/2005 ...
|
by: Paolo |
last post by:
I am having some problem with a Year Function.
I have form on which I have 4 field which indicate dates and an
additional form which sums those dates:
These are the fields:
YEARS...
|
by: mcbill20 |
last post by:
Hello all. I have a really basic question that I hope someone has a
better answer for. I apologize in advance-- I know this is probably a
really basic question but I am used to Oracle rathern than...
|
by: kevinjwilson |
last post by:
I am trying to get the date difference between two dates but I don't
want the function to include weekends in the calculation. Does anyone
have an idea on how to make this work?
|
by: J-P-W |
last post by:
Hi,
I have a system that records insurance policies.
If the policy is cancelled then any part of a month insured is deducted
from the premium, so a policy that ran for 32 days would get a 10...
|
by: AccessIdiot |
last post by:
Wow I'm failing miserably today. :-(
I have a table with three colums: fill_start, fill_end, fill_dur. Fill_dur is supposed to calculate the difference in minutes between fill_start and fill_end....
|
by: StevoNZ |
last post by:
Hi,
I am a little stuck with a query I am trying to build. Attemting to calculate the delivery time for a material.
I have managed to utilise the DateDiff function, but have some additional...
|
by: stephenmcnutt |
last post by:
I'm trying to do something that should be trivial. I'm a teacher at an elementary school, and I'm setting up an ASP form page for teachers to vote each afternoon on which dismissal line behaved...
|
by: mfuentes74 |
last post by:
I have a DateDiff calculation which well return negatives times I need to make the negative times zero. My calculation is
DateDiff("n",,)
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |