我需要計算生產力。時間以小時或分鐘爲單位SQL Server
Productivity = some count/ no of Hrs
我在HH:MM
例如時間,如果我花時間1 hrs 30 minutes
生產力將是
Productivity = some count/1.3?
OR
Productivity = some count/1.5?
我需要計算生產力。時間以小時或分鐘爲單位SQL Server
Productivity = some count/ no of Hrs
我在HH:MM
例如時間,如果我花時間1 hrs 30 minutes
生產力將是
Productivity = some count/1.3?
OR
Productivity = some count/1.5?
如果你有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分鐘。
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
您目前的方法無效。 'Datediff(小時,)'會輪到你,你不會把分鐘變成小數小時。這將使您的計算關閉。 –
@亞當溫格你是對的。忘記添加分鐘位:\ –
1小時30分鐘是1.5小時。 – Kevin