Dim sdate As Date = "2018-04-15" Dim edate As Date = "2018-04-18" Dim d As Date = sdate DataTables("出勤明细表").Datarows.Clear Do While d <= edate For Each dr As DataRow In DataTables("人员名单").Select("状态='在职'") Dim drs = DataTables("kq").Select("pin like '%" & dr("工号") & "' and checktime >= #" & d & "# and checktime < #" & d.AddDays(1) & "#", "checktime") Dim ndr As DataRow = Nothing 'DataTables("出勤明细表").find("工号='" & dr("工号") & "' and 日期=#" & d & "#") If ndr Is Nothing Then ndr = DataTables("出勤明细表").AddNew ndr("工号") = dr("工号") ndr("姓名") = dr("姓名") ndr("日期") = d If drs.count >= 1 Then ndr("考勤1") = cstr(drs(0)("checktime")).split(" ")(1) End If If drs.count >= 2 Then ndr("考勤2") = cstr(drs(drs.count-1)("checktime")).split(" ")(1) ndr("状态") = Nothing Else ndr("状态") = "异常" End If Next d = d.AddDays(1) Loop
|