Dim dtb As New DataTableBuilder("统计表1")
dtb.AddDef("name", Gettype(String), 32)
dtb.AddDef("recgroup", Gettype(String), 32)
dtb.AddDef("cardno", Gettype(String), 32)
dtb.AddDef("date", Gettype(Date))
dtb.AddDef("t1", Gettype(String))
dtb.AddDef("t2", Gettype(String))
dtb.Build
Dim drs As List(Of DataRow) = DataTables("表A").Select("","CardNo,time")
Dim drpre As DataRow = drs(0)
Dim drnew As DataRow = DataTables("统计表1").Addnew
drnew("name") = drpre("recName")
drnew("recgroup") = drpre("recgroup")
drnew("CardNo") = drpre("CardNo")
Dim d As Date = drpre("time")
drnew("date") = drpre("time").Date
Dim d2 As Date = new Date(d.Year,d.Month,d.Day,12,0,0)
If d < d2 Then
drnew("t1") = Format(drpre("Time"),"HH:mm")
Else
drnew("t2") = Format(drpre("Time"),"HH:mm")
End If
For i As Integer = 1 To drs.Count - 1
drpre = drs(i)
If drnew("CardNo") = drpre("CardNo") AndAlso drnew("date") = drpre("time").Date Then
d = drpre("time")
d2 = new Date(d.Year,d.Month,d.Day,12,0,0)
If d < d2 Then
drnew("t1") = Format(drpre("Time"),"HH:mm")
Else
drnew("t2") = Format(drpre("Time"),"HH:mm")
End If
Else
drnew = DataTables("统计表1").Addnew
drnew("name") = drpre("recName")
drnew("recgroup") = drpre("recgroup")
drnew("CardNo") = drpre("CardNo")
d = drpre("time")
drnew("date") = drpre("time").Date
d2 = new Date(d.Year,d.Month,d.Day,12,0,0)
If d < d2 Then
drnew("t1") = Format(drpre("Time"),"HH:mm")
Else
drnew("t2") = Format(drpre("Time"),"HH:mm")
End If
End If
Next
[此贴子已经被作者于2016/11/18 16:54:30编辑过]