10.8 有关工作日的计算

 

计算 N 个工作日后的日期。
统计 2014 年中,各员工有几次超过 10 个工作日还没有解决客户问题。部分数据如下:

ID CustomerID EmployeeId QuestionDate SolveDate
1 OLDWO 2 2014/01/01 2014/01/09
2 WELLI 7 2014/01/01 2014/01/07
3 LAUGB 2 2014/01/01 2014/01/07
4 LINOD 8 2014/01/02 2014/01/08
5 REGGC 5 2014/01/02 2014/01/12

函数 workday(t,k,h) 计算和日期 t 相距 k 个工作日的日期,h 是 (非) 假日序列,即 h 中成员若非周末则是假日,是周末则非假日,若为周末时按调休计算,调为工作日。

脚本:

A
1 =T(“AfterSale.csv”;“,”)
2 [2014/01/01,2014/01/26,2014/01/31,2014/02/03,2014/02/04,2014/02/05,2014/02/06,2014/02/08,2014/04/07,2014/05/01,2014/05/02,2014/05/04,2014/06/02,2014/09/08,2014/09/28,2014/10/01,2014/10/02,2014/10/03,2014/10/06,2014/10/07,2014/10/11]
3 =A1.select(year(QuestionDate)==2014 && workday(QuestionDate, 10, A2) < SolveDate)
4 =A3.groups(EmployeeId; count(~):Count)

A1 导入售后表
A2 定义 2014 年节日
A3 使用 workday() 函数计算 10 个工作日后的日期,去除节日
A4 按员工分组汇总,统计次数

运行结果:

EmployeeID Count
1 2
2 1
3 2