Click here to Skip to main content
15,919,341 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
i have one table look like:

Checkin ****** Ckeckout ***** Difference
--------------- --------------- -------------
8/19/2013 08:19 ***** 8/19/2013 10:19
8/19/2013 11:10 ***** 8/19/2013 12:19

In this i want the difference of checkin column and checkout row column in Difference column...
Posted
Updated 25-Aug-13 18:08pm
v3

Try this.

select DATEDIFF(MI,'8/19/2013 08:19','8/19/2013 10:19')
 
Share this answer
 
Comments
Nawab Ahmad 26-Aug-13 0:46am    
checkin checkout
8/19/2013 14:53 NULL
8/19/2013 16:46 NULL
8/19/2013 08:20 8/19/2013 08:50
8/19/2013 12:40 8/19/2013 13:20
NULL 8/19/2013 13:22
NULL 8/19/2013 14:52
NULL 8/19/2013 18:22
NULL 8/19/2013 16:21
NULL 8/19/2013 16:45
NULL 8/19/2013 16:45
NULL NULL

i am executing one query to insert the value from other table in checkin
INSERT INTO diff(CHECKIN ) SELECT checktime from checkinout where sensorid='1'
working fine
but when i m trying to execute the other query to insert the value in checout

INSERT INTO diff(CHECKout ) SELECT checktime from checkinout where sensorid='2'

it can't replace the null value

it is coming like this..
8/19/2013 14:53 NULL

but i want to be like..
8/19/2013 14:53 8/19/2013 8:50
ArunRajendra 26-Aug-13 1:08am    
You need to update the column CHECKout for records created for CHECKIN. Insert will always make a new entry.
Nawab Ahmad 26-Aug-13 1:19am    
thank for ur reply..
what i need to modify in this query to makeit work..

INSERT INTO diff(CHECKout ) SELECT checktime from checkinout where sensorid='2'
You can calculate difference using DATEDIFF function like
DATEDIFF(option,'1997-12-31 23:59:59','1997-12-30')  
 
Share this answer
 
v3
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900