Hello,

I have a query from a MS-SQL database regarding the in and out executed by a user and i'm stuck at the calculation of time spend inside.

Can sommone please give me an advice how to procede with the query and calculation of the next formula ?

Code:
SELECT DISTINCT 
dbo.tblEvents.dEvent_Date,
dbo.tbl_tmp.tbl_val,
dbo.tblEmployees.tFirstName + ' ' + dbo.tblEmployees.tLastName AS TMP,
dbo.tblDepartment.tDepartmentName,
CONVERT(char(10), dEvent_Date, 105) AS DateOrdered,
CONVERT(char(10), dEvent_Date, 108) AS TimeOrdered, 
CONVERT(char(10), dEvent_Date, 108) AS TimeOrdered2

FROM
dbo.tblEvents

LEFT OUTER JOIN dbo.tblEmployees ON dbo.tblEmployees.iEmployeeNum = dbo.tblEvents.iUserNum
LEFT OUTER JOIN dbo.tblDepartment ON dbo.tblEmployees.iDepartmentID = dbo.tblDepartment.mID 
LEFT OUTER JOIN dbo.tbl_tmp ON dbo.tblEvents.iReader = dbo.tbl_tmp.tbl_id



WHERE
dbo.tblEvents.iUserNum NOT LIKE 0 AND
dbo.tblEvents.tByte7 NOT LIKE 33 AND
dbo.tblEvents.iReader BETWEEN 15 AND 18 AND
dbo.tblDepartment.tDepartmentName = 'Livrare' AND
dbo.tblEvents.iUserNum = '72' AND
dbo.tblEvents.dEvent_Date BETWEEN '2012-03-01 00:00:00.000' AND '2012-03-20 23:59:59.000'
ORDER BY
dbo.tblEvents.dEvent_Date DESC



TABLE Image

Sorry i can't attach the image so i put a link with the jpg

http://calberson.ro/query_mssql.jpg

I whant to make a calculation from the IN to the OUT field and displayed in a new row as minutes spend betwen that 2 date/time.


Thanks for any support that you give me.
Please excuse my english and the fact that i'm at the first time posting to this forum.