CREATE TABLE #tblAttendance
(
[AttendanceLogId] [int] IDENTITY(1,1) NOT NULL,
[FK_ServiceTypeId] [int] NOT NULL,
[FK_ClientId] [int] NULL,
[FK_EmpMasterId] [int] NOT NULL,
[VehicleCode] nvarchar NULL,
[JobSite] nvarchar NULL,
[VendorCode] nvarchar NULL,
[Location] nvarchar NULL,
[DayWorkingStart] time NULL,
[DayWorkingEnd] time NULL,
[NightWorkingStart] time NULL,
[NightWorkingEnd] time NULL,
[TotalHoursWorked] time NULL,
[ApprovedHours] [float] NULL,
[OTHours] [float] NULL,
[Supervisor] nvarchar NULL,
[Remarks] nvarchar NULL,
[RigManager] nvarchar NULL,
[AttendanceDate] [date] NULL,
[CreatedDate] [datetime] NULL,
[ModifiedDate] [datetime] NULL,
[StatusFlag] [int] NULL,
)
insert into #tblAttendance
(FK_ServiceTypeId,FK_ClientId,FK_EmpMasterId,VehicleCode,JobSite,VendorCode,[Location],DayWorkingStart,DayWorkingEnd,NightWorkingStart,NightWorkingEnd,TotalHoursWorked,
ApprovedHours,OTHours,Supervisor,Remarks,RigManager,AttendanceDate,CreatedDate,StatusFlag)
values
(1 ,1,1,'1001','Sp676','LIV234',null,'06:00:00','18:00:00','06:00:00','18:00:00',
null,null,null,null,null,null,null,getdate(),1
)
SELECT @id=SCOPE_IDENTITY()
declare @start as varchar(10)
declare @end as varchar(10)
declare @hours as varchar(10)
declare @mins as varchar(10)
--set @start=DATEDIFF(minute,@dayendtime,@daystarttime)
--set @end=DATEDIFF(minute,@nightendtime,@nightstarttime)
--set @hours= (@start+@end)/60
--set @mins= (@start+@end)%60
declare @t1 int,@t11 int
declare @t2 int,@t12 int
declare @t3 int,@t13 int
declare @t4 int,@t14 int
declare @timehrs int
declare @timemin int
declare @time varchar(10)
select @t1 = datepart(HOUR,@dayendtime)
select @t2 = datepart(HOUR,@daystarttime)
select @t3 = datepart(HOUR,@nightendtime)
select @t4 = datepart(HOUR,@nightstarttime)
select @t11 = datepart(MINUTE,@dayendtime)
select @t12 = datepart(MINUTE,@daystarttime)
select @t13 = datepart(MINUTE,@nightendtime)
select @t14 = datepart(MINUTE,@nightstarttime)
declare @tothrs varchar(10)
set @timehrs =(@t1+@t2+@t3+@t4)
set @timemin =(@t11+@t12+@t13+@t14)
set @tothrs = cast(@timehrs as varchar)+':'+cast(@timemin as varchar)
update #tblAttendance
set
TotalHoursWorked=@tothrs
where AttendanceLogId=@id
commit transaction
end
the problem is when i am trying to update #tblAttendance.TotalHoursWorked it is not calculating in 24hrs foramt
it is storing as TotalHoursWorked = 48:00
where as i need to store 24:00