About This Code
Brief Description:
Determines if current time is in between two times
Contributor:
Niel Revelle
Type:
Date/Time functions
Last Modified:
14 Jul 2005
OpenNTF Disclaimer
All of the program code and information presented in the OpenNTF.org Code Bin are provided "as-is", and should be used at your own risk. OpenNTF.org make no express or implied warranty about anything in the Code Bin, and OpenNTF.org will not be responsible or liable for any damage caused by the use or misuse of anything from this site. OpenNTF.org makes no guarantees about anything. Please thoroughly test all of the knowledge and code you find here before you attempt to use them in your production environment.
Code / Description
Function InRange(StartTime As Variant, EndTime As Variant) As Boolean
Dim Results As Boolean
Dim CurrentTime As Variant
currentTime = Time()
If StartTime < EndTime Then
If (currentTime >= StartTime) And (currentTime <= EndTime) Then
Results = True
Else
Results = False
End If
Else
If (currentTime >= StartTime) Then
Results = True
Elseif (currentTime <= EndTime) Then
Results = True
Else
Results = False
End If
End If
InRange = Results
End Function
Usage / Example
/timeRange is a multivalue date/time field set to only display the time
times = ruleDoc.GetItemValue("TimeRange")
If InRange(times(0),times(1)) Then
'Do Stuff
End If
Comments
Posted by Mark Teichmann on 11/17/2005 12:59:26 AMFor time differences I would use notesDateTime.TimeDifference( notesDateTime )
I think it is better to evaluate the time difference with notesDateTime.TimeDifference( notesDateTime ) and then use the result for further processing.