如何将日期转换为日期范围?

时间:2019-10-08 20:11:24

标签: sql sql-server

我目前正在从Kronos休假模块中提取数据。数据是关于雇员的,他离开的日期是什么原因和地位。因此,日期是挑战所在,因为我需要将日期转换为日期范围,而不是逐日将其转换为当前日期。

当前文件:

Absence_ID  |Person_num  |Work_type   |Leave_type  |Segement_Start_Date  |Segement_End_Date   |Status
------------|------------|------------|------------|---------------------|--------------------|-----------------------
11617       |200146      |C           |VERMOUNT    |01/28/2019 0:00      |01/28/2019 0:00     |Closed-Returned to Work
11617       |200146      |C           |VERMOUNT    |01/29/2019 0:00      |01/29/2019 0:00     |Closed-Returned to Work
11617       |200146      |C           |VERMOUNT    |01/30/2019 0:00      |01/30/2019 0:00     |Closed-Returned to Work
11617       |200146      |C           |VERMOUNT    |01/31/2019 0:00      |01/31/2019 0:00     |Closed-Returned to Work
11617       |200146      |C           |VERMOUNT    |02/01/2019 0:00      |02/01/2019 0:00     |Closed-Returned to Work
11617       |200146      |C           |VERMOUNT    |02/04/2019 0:00      |02/04/2019 0:00     |Closed-Returned to Work
11617       |200146      |C           |VERMOUNT    |02/05/2019 0:00      |02/05/2019 0:00     |Closed-Returned to Work
11617       |200146      |C           |VERMOUNT    |02/06/2019 0:00      |02/06/2019 0:00     |Closed-Returned to Work
11617       |200146      |C           |VERMOUNT    |02/07/2019 0:00      |02/07/2019 0:00     |Closed-Returned to Work
11617       |200146      |C           |VERMOUNT    |02/08/2019 0:00      |02/08/2019 0:00     |Closed-Returned to Work

已更正:

Absence_ID  |Work_type   |Leave_type  |Segement_Start_Date |Segement_End_Date   |Status  
------------|------------|------------|--------------------|--------------------|--------
11617       |C           |VT-FML      |01/28/2019          |02/08/2019          |Approved

1 个答案:

答案 0 :(得分:0)

按缺勤ID,工作类型,休假类型分组,选择最小开始日期和最大结束日期。