Dim nms As String
Dim n As Integer = 6 '未来天数,含今天,所以实际是未来7天
For Each dr As DataRow In DataTables("对私客户明细").DataRows
Dim dt As Date = dr("生日")
Dim dt1 As New Date(Date.Today.Year,dt.Month,dt.Day)
Dim dt2 As New Date(Date.Today.AddDays(n).Year,dt.Month,dt.Day)
If (dt1 >= Date.Today AndAlso dt1 < Date.Today.AddDays(n)) OrElse (dt2 >= Date.Today AndAlso dt2 < Date.Today.AddDays(n)) Then
nms = nms & ",'" & dr("身份证号") & "'"
End If
Next
If nms > "" Then
nms = nms.Trim(",")
Tables("对私客户明细").filter = "[身份证号] In (" & nms &")"
End If
如果身份证号有2月29日的数据,程序报错年、月,日无法描述。版主您看是否是代码有问题。