Click here to Skip to main content
15,115,146 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi,,

I have table with columns like Empno,empname, date, Intime, outtime.
And i want to write a stored procedure for when employee In/Out ..calculating total Intime and Outtime for every swipe...

Calculating Intime and Outtime for every swipe in stored procdure ..?

How to do this plzz tell me asap..?


Thanks in advance..
Posted
Updated 14-Jun-12 8:25am
v2
Comments
harshada3 14-Jun-12 6:17am
   
which datatype used for Intime,outtime
Ganesh_mca 14-Jun-12 7:06am
   
integer only used
Vedangi 14-Jun-12 7:29am
   
Is there any identity column in your table ???

1 solution

Use MSDN: DATEDIFF (Transact-SQL)[^] to find the time difference between InTime & OutTime.

Put something like this query in stored procedure.

For a given employeeId:
SQL
SELECT  
   EmpName,
   DATEDIFF(hour, Intime, Outtime) as HourTime
FROM
   Employees
WHERE
   Empno = @EmployeeNo
   
Comments
Espen Harlinn 14-Jun-12 16:37pm
   
5'ed!
Sandeep Mewara 15-Jun-12 2:59am
   
Thanks Espen. :)
Manas Bhardwaj 15-Jun-12 4:00am
   
+5
Sandeep Mewara 16-Jun-12 4:47am
   
Thanks.
Ganesh_mca 22-Jun-12 4:54am
   
Thanks
Sandeep Mewara 22-Jun-12 5:47am
   
Welcome.

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