An example (with some fixes from my quick post):create table testdates(userid int,stdt datetime,edt datetime,dt datetime)goinsert into testdates values (1,'2004-05-01 08:00:00.000','2004-05-01 17:00:00.000','2004-05-01 08:00:00.000')insert into testdates values (1,'2004-05-02 08:00:00.000','2004-05-02 17:00:00.000','2004-05-01 08:00:00.000')insert into testdates values (1,'2004-05-03 08:00:00.000','2004-05-03 17:00:00.000','2004-05-01 08:00:00.000')insert into testdates values (1,'2004-04-04 08:00:00.000','2004-04-04 17:00:00.000','2004-04-01 08:00:00.000')insert into testdates values (2,'2004-05-05 08:00:00.000','2004-05-05 17:00:00.000','2004-05-01 08:00:00.000')insert into testdates values (3,'2004-04-06 08:00:00.000','2004-04-06 17:00:00.000','2004-04-01 08:00:00.000')goselect userid,sum(datediff(hour,stdt,edt)) as month_hoursfrom testdateswhere datepart(month,dt) = 5group by userid
outputs:userid month_hours ----------- ----------- 1 272 9(2 row(s) affected)
*##* *##* *##* *##* Chaos, Disorder and Panic ... my work is done here!