2月29日的问题
Dim d1 As Date = "2012-9-1"
Dim d2 As Date = "2010-9-1"
Dim n As Integer = 30 '未来30天
Dim idxs As String = ""
For Each dr As DataRow In DataTables("表A").Select("上牌日期 is not null")
Dim dt As Date = dr("上牌日期")
Dim dt1 As Date
Dim dt2 As Date
If dt.month = 2 AndAlso dt.Day = 29 Then
dt1 = new Date(Date.Today.Year,dt.Month,28)
dt2 = New Date(Date.Today.AddDays(n).Year,dt.Month,28)
Else
dt1 = new Date(Date.Today.Year,dt.Month,dt.Day)
dt2 = New Date(Date.Today.AddDays(n).Year,dt.Month,dt.Day)
End If
If (dt1 >= Date.Today AndAlso dt1 < Date.Today.AddDays(n)) OrElse (dt2 >= Date.Today AndAlso dt2 < Date.Today.AddDays(n)) Then
If dt >= d1 Then
Dim y As Integer = dt.Year - d1.Year
If y = 2 OrElse y = 4 OrElse y >= 6 Then
idxs &= dr("_Identify") & ","
End If
Else If dt > d2 AndAlso dt < d1 Then
Dim y As Integer = dt.Year - d1.Year
If y > 0 AndAlso y Mod 2 = 0 OrElse dt2.Year >= 2016 Then
idxs &= dr("_Identify") & ","
End If
Else If dt < d2 Then
Dim y As Integer = dt.Year - d1.Year
If dt2.Year >= 2016 Then
idxs &= dr("_Identify") & ","
End If
End If
End If
Next
Tables("表A").Filter = "_Identify in (" & idxs.trim(",") & ")"