【发布时间】:2017-11-29 12:08:23
【问题描述】:
我想在 SQL Server 2008 R2 中创建一个函数,它在通过 2 个参数 @ShiftStart 和 @ShiftEnd 时返回非加班时间(非加班)。加班时间固定在 22:00 - 06:00 之间。我们想要不在这些加班时间的非加班时间。 少数情况,结果如下图。
Case No ShiftStart ShiftEnd Non-OT Hours
1. '2017-12-28 05:00:00.000' '2017-12-28 08:00:00.000' 2 calculated like this (06:00 - 08:00)
2. '2017-12-28 20:00:00.000' '2017-12-28 23:00:00.000' 2 calculated like this (22:00 - 20:00)
3. '2017-12-28 22:00:00.000' '2017-12-29 01:00:00.000' 0 as this shift is inside the OT hours
4. '2017-12-28 20:00:00.000' '2017-12-29 02:00:00.000' 2 calculated like this (22:00 - 20:00)
请帮忙写函数 fn_GetNonOTHours(@ShiftStart,@ShiftEnd)
谢谢
【问题讨论】:
-
请展示您尝试过的内容,遇到的任何问题。 stackoverflow.com/help/how-to-ask
-
SO 不是免费的编码服务。你需要展示你到目前为止所取得的成就以及你陷入困境的地方。
标签: sql-server tsql sql-server-2008-r2