maybe this code could help:
daydifference = DateDiff("d", datevalue1, datevalue2)
hour = DatePart("h", datevalue1)
If daydifference <= 1 Then
If hour >= 23 Or hour <= 2 Then
IsValid = True
If hour = 2 And min > 0 Then
IsValid = False
End If
Else
IsValid = False
End If
Else
IsValid = False
End If