如何计算小时数,计算日,加时间和进出时间 [英] How to hours, calculate day , overtime from in and OUT time
问题描述
我有IN时间和外出时间,其中我从IN和Out时间计算小时数,现在我想要当小时= 8然后Day将是1并且如果小时多于8小时(例如:12小时减去从8小时= 4小时然后4小时乘以100分钟)
i想要商店程序...
我尝试过:
SELECT INTime,Outtime,DATEDIFF(Hour,INTime,Outtime)AS Hours
如果
Hours = 8
FROM EmployeeAttedance
我将修复你拥有的SQL语句DECLARE @ punches TABLE (PunchIn time ,PunchOut time )
INSERT @ punches VALUES (' 07:58',' 16:15')
SELECT PunchIn,PunchOut
,[Hours] = DateDiff(小时,PunchIn,PunchOut)
,[天数] = CASE WHEN DateDiff(小时,PunchIn) ,PunchOut)> = 8 那么 1 ELSE 0 END
FROM @ punches我必须让你知道有一些潜在的缺陷在你的逻辑中。
1-如果有人在16小时内进行双班制,那么这将是2天吗?
2-如何在夜班工作?
3-如果有人在1天工作,你是否希望减少工作时间8?
i have IN Time and Out Time ,in which i am calculating Hours from IN and Out Time,Now i want that when hours =8 then Day will be 1 and if Hours is more then to 8hours(for example :12hours minus from 8hours =4hours then 4hours multiply to 100rate)
i want store procedure ...
What I have tried:
SELECT INTime, Outtime, DATEDIFF(Hour, INTime, Outtime) AS Hours if Hours = 8 FROM EmployeeAttedance
I will fix the SQL statement that you haveDECLARE @punches TABLE ( PunchIn time, PunchOut time ) INSERT @punches VALUES ('07:58', '16:15') SELECT PunchIn, PunchOut , [Hours] = DateDiff(Hour, PunchIn, PunchOut) , [Days] = CASE WHEN DateDiff(Hour, PunchIn, PunchOut) >= 8 THEN 1 ELSE 0 END FROM @punchesI must let you know that there are a few potential flaws in your logic.
1- If someone works a "double-shift" for 16 hours, would this be 2 days?
2- What about someone working an overnight shift?
3- If someone did work 1 day, did you want the hours reduced by 8?
这篇关于如何计算小时数,计算日,加时间和进出时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!