Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datetime Validation

Status
Not open for further replies.

DerPflug

Programmer
Mar 28, 2002
153
US
How can I verify that a datetime is within one day's difference of the current date and between 11pm and 2am?
 
I did this:

Code:
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
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top