Pages

Thursday, March 31, 2011

Retriving Total Hours and Minuts From time Data Type

Table Structure:

CREATE TABLE Worklog(
EmpNo int,
Date Date,
TimeSpent time(5))

Data

EmpNo    Date                 TimeSpent
1              01/01/2011    12:12:00
1              02/01/2011   10:12:00
1              04/01/2011   05:08 :00

SELECT   SUM(DATEDIFF(MI,’00:00:00′,Worklog.TimeSpent))/60 as Hours,SUM(DATEDIFF(MI,’00:00:00′,Worklog.TimeSpent))%60 as minute from Worklog

No comments:

Post a Comment