希望比较文本框中的两个日期,如果它们匹配则返回“未刷新”
没有什么新意
Public Function CourseStatus(ByVal RefDate2 As Variant) As String
Dim Description As String
If Len(RefDate2) > 0 And IsDate(RefDate2) Then
Select Case DateDiff("d", Date, RefDate2)
Case Is > 60
CourseStatus = "In Date"
Case Is > 0
CourseStatus = "Expiring"
Case Is = [ParticipationDate]
CourseStatus = "Not Refreshed"
Case Else
CourseStatus = "Expired"
End Select
Else
CourseStatus = "Please Book"
End If
End Function
我想比较[ParticipationDate]
和[RefDate2]
,如果它们匹配,则返回“ Not Refreshed”作为CourseStatus。我需要先执行此操作,然后再运行其余代码以赋予“日期”,“到期”,“已到期”,并且如果都不适用,则显示“请预订”
例如
ParticipationDate 1/1/19
RefDate2 1/1/19
CourseStatus "Not Refreshed"
答案 0 :(得分:0)
对不起,我没有非常准确地阅读您的代码。 您的datediff函数返回一个整数值而不是一个日期。您应该使用
Case is 0
检查日期是否匹配。
答案 1 :(得分:0)
您可能会使用以下内容:
If Len(RefDate2) > 0 And IsDate(RefDate2) Then
Select Case DateDiff("d", Date, RefDate2)
Case Is > 60
CourseStatus = "In Date"
Case Is > 0
CourseStatus = "Expiring"
Case Else
If DateDiff("d", RefDate2, [ParticipationDate]) = 0 Then
CourseStatus = "Not Refreshed"
Else
CourseStatus = "Expired"
End If
End Select
Else
CourseStatus = "Please Book"
End If