小编Dan*_*n B的帖子

检测两个时间段是否重叠

我有一个 HR 系统,我需要检测新的请假(休假)请求是否与现有的请求冲突。我已经根据一整天的时间编写了代码来做到这一点;我现在需要做基于半天的比较。

这是我的数据结构(和数据格式)。我正在使用 SQL Server 2008 R2。

StartDate     (datetime)
EndDate       (datetime)
Run Code Online (Sandbox Code Playgroud)

以下 2 个变量显示用户是休息半天还是一整天。列出并解释了每个选项的选项。

StartDateAMPM (int) 0=All Day (StartDate may or may not be the same as the EndDate), 
                    1=AM, (User is out of the office only in the morning)
                    2=PM  (User is out of the office only in the afternoon)

EndDateAMPM   (int) 0="All Day" / "half day" / "StartDate = EndDate", 
                    1=AM (The user is off for the morning only)

**NOTE This cannot be PM (as you cannot …
Run Code Online (Sandbox Code Playgroud)

sql-server t-sql sql-server-2008-r2

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

sql-server ×1

sql-server-2008-r2 ×1

t-sql ×1