Compare Method for LCDatetime
This method compares two Datetime values and returns the relationship.
Defined In
LCDatetime
Syntax
Result = thisDatetime.Compare (baseDatetime)
Parameters
Parameter |
Description |
---|---|
baseDatetime |
The Datetime to which to compare thisDatetime. |
Return Value
Value |
Description |
---|---|
Result |
Long. Result of the comparison: |
Result > 0 (positive): thisDatetime is greater than baseDatetime. |
|
Result < 0 (negative): thisDatetime is less than baseDatetime. |
|
Result = 0: thisDatetime is equal to baseDatetime. |
|
Certain datetime "constants" will always return greater, less or equal to any valid date. See the SetConstant method for details. The comparison takes into account time zones and Daylight Savings time; for instance, 1:30 PM CST is considered earlier than 1:00 PM EST on the same date. Note: For control over whether
time zones and Daylight Savings Time are taken into account, or to
test for equality only to the nearest second (as opposed to hundredth
of a second), use LCField.Compare instead. |
Example
Option Public
Uselsx "*lsxlc"
Sub Initialize
Dim Clock As New LCDateTime (1999, 12, 31, 23, 59, 59, 99)
Dim Match As New LCDatetime
Match.SetCurrent
If (Clock.Compare (Match) = 0) Then
Print "The current time matches " & Clock.Text
Elseif (Clock.Compare (Match) > 0) Then
Print "The current time is before " & Clock.Text
Else
Print "The current time is after " & Clock.Text
End If
End Sub
Example Output
The current time is before 12/31/1999 11:59:59.99 PM