Hi,
I have a little problem. I have 4 datetime values.
2008-01-04 11:33:05.000,
2008-01-04 12:12:44.000,
2008-01-04 12:22:43.000,
2008-01-04 17:14:03.000
All these are For the same date.I want to write a function to get the total time difference like this.
2008-01-04 12:12:44.000 - 2008-01-04 11:33:05.000 = 27s
2008-01-04 17:14:03.000 - 2008-01-04 12:22:43.000= 6:52
Then to add them up 27+6.52= 7 hrs and 19 minutes.
Can someone plz give me a coding to write this.
This was the sp that i wrote earlier.This will return the employee in time and out time.But thats not the way i want it to be.I want the in between time slots also to get the total time and add them up.
CREATE PROC [dbo].[sp_TotalAttendanceSummary](@EmployeeIdList nvarchar(MAX),@StartDate Datetime,@EndDate DateTime)
AS
create
table #TotalAttendance(
Date
datetime,
Employeename
varchar(200),
Intime
datetime,
Outtime
datetime,
Totaltime
char(10))
insert
into #TotalAttendance(Date,Employeename,Intime,Outtime)
Select
distinct CONVERT(VARCHAR(10), MovementDateTime, 101) AS Date,
Employee
.EmployeeName,
min(MovementDateTime),
max(MovementDateTime)
from
MovementInformation
INNER
JOIN Employee ON (MovementInformation.EmployeeId = Employee.Id)
where
MovementDateTime between @StartDate and @EndDate
and
MovementInformation
.EmployeeId in (select * from dbo.GetIds(@EmployeeIdList))
group
by CONVERT(VARCHAR(10), MovementDateTime, 101),EmployeeName
update
#TotalAttendance
SET
Totaltime =CONVERT(CHAR(8),(SELECT OutTime-InTime),8)
Thanks.
Lucki