Dim dt1 As Date = #11/14/2016#
Dim dt2 As Date = #11/14/2016#
Dim dtb As New DataTableBuilder("统计表1")
dtb.AddDef("name", 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
For Each dr1 As DataRow In DataTables("AtdRecord88").DataRows
For i As Integer = 0 To (dt2 - dt1).TotalDays
Dim dr2 As DataRow
dr2 = DataTables("统计表1").Addnew
dr2("name") = dr1("recName")
dr2("CardNo") = dr1("CardNo")
dr2("date") = dt1.AddDays(i)
Dim drs As List(of DataRow) = DataTables("AtdRecord88").Select("CardNo = '" & dr2("CardNo") & "'And Time >= #" & dr2("Date") & "# And Time < #" & dr2("Date").AddDays(1) & "# ")
For n As Integer = 0 To drs.count -1
If n = 0 Then
dr2("t1") = Format(drs(n)("Time"),"HH:mm")
ElseIf n = 1 Then
dr2("t2") = Format(drs(n)("Time"),"HH:mm")
Exit For
End If
Next
Next
Next