Dim ids As String
Dim n As Integer = 30 '未来天数,含今天,所以实际是未来30天
For Each dr As Row In Tables("员工基础表").Rows
Dim dt As Date = dr("出生日期")
If dt.Month = 2 AndAlso dt.Day = 29
dt = "#2/28/" & dr.Year &"#" ' 在这里处理一下日期,统一将闰年的29日都改为28日
End If
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
ids = ids & "," & dr("_Identify")
End If
Next
If ids > "" Then
ids = ids.Trim(",")
Tables("员工基础表").filter = "[_Identify] In (" & ids &")"
MessageBox.show("近30天内过生日的员工有 " & Tables("员工基础表").Rows.Count & " 名!,请及时慰问.","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning)
Else
MessageBox.show("近30天内没有过生日的员工!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning)
End If
[此贴子已经被作者于2019/6/26 10:02:27编辑过]