【发布时间】:2021-08-18 23:01:11
【问题描述】:
我有 3 个不同的日期,我正在尝试编写最接近的即将到来的日期。如果日期是过去的,则需要忽略它。另外,date1
我已尝试使用 (8/18/2021, 8/19/2021, 8/20/2021) 作为输入的以下代码,但函数返回 12:00:00AM 而不是 8/18/2021
Public Function UpcomingDates(date1 As Date, date2 As Date, date3 As Date) As Date
Dim ClosestDate As Date
If date1 >= Date Then 'diff1 >= 0
ClosestDate = date1
ElseIf date2 >= Date Then
ClosestDate = date2
ElseIf date2 >= Date Then
ClosestDate = date3
End If
End Function
为什么函数不返回 8/18/2021?
*我在 MS Access Query 中使用 VBA
【问题讨论】:
-
您还没有设置函数返回值,只是声明了它将返回的数据类型 - 尝试在
End Function之前添加UpcomingDates=ClosestDate。
标签: ms-access