Getting different results
Hi,
Im trying to calculate how many hrs a user wroked weekly, however i'm getting different results
1) i'm trying to get the time using the 'between' function for a specfic week
Code:
SELECT [userID] , CAST(SUM(workingtime) / 60 AS varchar(5)) + ':' + RIGHT('0' + CAST(SUM(workingtime) % 60 AS varchar(2)), 2)
FROM yyyyy
where datee between '01/04/2014' and '01/11/2014'
group by userID
for user A i'm getting = 58 for that specific week
2)i tried to do the same thing but with a different code, and i get a different result for user A which is 52hrs for that specific week
Code:
SELECT userID, CONVERT(varchar(50), (DATEADD(dd, @@DATEFIRST - DATEPART(dw, datee), datee)), 101), CAST(SUM(workingtime) / 60 AS varchar(5)) + ':' + RIGHT('0' + CAST(SUM(workingtime) % 60 AS varchar(2)), 2) AS Expr1
FROM yyy
GROUP BY userID, CONVERT(varchar(50), (DATEADD(dd, @@DATEFIRST - DATEPART(dw, datee), datee)), 101)
I tried to alternate the first and last day of the week but still i don't get the same result?
I'm not sure why i'm getting different results, any help will be appreciated.
Thanks
Re: Getting different results
Post sample data. People need to see how the data is organized in your table (data type included).