我有一个函数,它需要一个时间,例如05:00:00,并用当前时间(和可选的另一个时间)检查它,如果参数中的时间已经过了,它应该返回相同的时间,但是是第二天。
例如,如果
tm = 05:00:00
现在=
2018-08-14 12:00:00
2018-08-15 05:00:00
,但如果时间还没有过去,例如。
tm = 19:00
2018-08-14 19:00
.
'Day Adjustment
Sub DayAdjust(tm As Double, Optional tm2 As Double = 0)
If tm2 = 0 Then
tm2 = DayAdjust(tm)
End If
If (Date + tm) < Now() Or (Date + tm) < tm2 Then
tm = (Date + 1 + tm)
End If
MsgBox tm
DayAdjust = tm
End Sub
Dim schStart, schEnd As Double
schStart = Range("cdh_schStart").Value
schStartTime = DayAdjust(CDbl(schStart))
schEnd = Range("cdh_schEnd").Value
schEndTime = DayAdjust(schEnd, schStart)
牢房
cdh_schStart
包含值
05:00:00
,和
cdh_schEnd
有
08:00:00
当前系统时间设置为
2018-08-14 18:30:00
在第三行,
schStartTime = DayAdjust(CDbl(schStart))
编译错误:
期望的函数或变量