Click here to Skip to main content
15,746,652 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I have a table named Attendance_Master and structure is as
AttendanceId int,
LoginTime datetime,
LogoutTime datetime,
DHours int,
DMinutes int,
MHours int,
MMinutes int

and values in the table is as

AttendanceId 1,
LoginTime '2010-12-21 15:45:17.500',
LogoutTime '2010-12-21 15:56:28.660',
DHours 0,
DMinutes 11,
MHours 0,
MMinutes 27

now my problem is that I want to subtract MHours from DHours and
MMinutes from MHours
but its

select LoginTime,LogoutTime,DHours,DMinutes,MHours,MMinutes,(Dhours-Mhours) as NetHours,(DMinutes-MMinutes)as NetMinutes from Attendance_Master
where convert(varchar,LoginTime,103)=convert(varchar,getdate(),103)

but minutes are coming as -26.
I want to change it into minutes
Updated 21-Dec-10 1:28am

1 solution

I would recommend using DateDiff for that. Have a look at the link below for more info:[^]

Good luck!
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