我需要计算生产力。
Productivity = some count/ no of Hrs
我有时间在HH:MM
例如,如果我需要时间1 hrs 30 minutes
生产力将是
Productivity = some count / 1.3?
OR
Productivity = some count / 1.5?
答案 0 :(得分:3)
如果你有1小时30分钟,那就是1.5小时。您可以将计算结果设为:yourValue / 1.5
以获得units / Hour
你可能想要这样的东西:
SELECT DATEPART(HOUR, @yourTime) + (DATEPART(MINUTE, @yourTime) / 60.) AS pHours;
或更完全类似于此,其中@Time
是任务花了多长时间:
SELECT @workAccomplished /
(DATEPART(HOUR, @Time) + (DATEPART(MINUTE, @Time) / 60.)) AS Productivity;
如果你除以1.3,你将计算1小时18分钟,0.3小时= 18分钟。
答案 1 :(得分:0)
declare @workaccomplished int = 240
declare @timeworked int = (SELECT DATEDIFF(hour, '2007-05-07 09:53:01', '2007-05-08 09:53:01'))
--datediff parameters: hour, startingtime , endtime
declare @productivity numeric(8,4) = @workaccomplished / @timeworked
select @productivity