我正在试图弄清楚如何更改此代码,以便它能够满足我的需求。我想基本上说,如果今天是星期五,时间是下午4点或更长时间,那么新的时间是星期一早上7点。这是我所拥有的,但我无法弄清楚它的TIME部分。
TiffTag.IMAGELENGTH
答案 0 :(得分:0)
这有点啰嗦,但似乎有效:
If Weekday(modDropOff) = 6 And Hour(modDropOff) >= 16 Then
modDropOff = DateSerial(Year(modDropOff), Month(modDropOff), Day(modDropOff)) + 3 + TimeSerial(7, 0, 0)
End If
答案 1 :(得分:0)
编辑日期的一些方法:
Option Explicit
Public Sub checkDate()
Dim modDropOff As Date
If Weekday(Now) = 2 And Hour(Now) >= 16 Then
modDropOff = (Date + 3) + TimeValue("07:00:00 AM")
Else
modDropOff = Now
End If
MsgBox Format(modDropOff, "ddd mmm dd, yyyy - hh:mm:ss AMPM")
End Sub
Public Sub editDate()
Dim modDropOff As Date
If Weekday(Now) = 2 And Hour(Now) >= 16 Then
modDropOff = DateAdd("d", 3, Now)
modDropOff = DateSerial(Year(Now), Month(Now), Day(Now) + 3) + TimeSerial(7, 0, 0)
Else
modDropOff = Time
End If
MsgBox Format(xDate, "ddd mmm dd, yyyy - hh:mm:ss AMPM")
End Sub
其他VBA日期和时间功能