GetDiff Method for LCDatetime
This method gets the difference between the values of two LCDatetime objects.
Defined In
LCDatetime
Syntax
difference = lcDatetime.GetDiff (baseDatetime, Units)
Parameters
Parameter |
Description |
---|---|
baseDatetime |
LCDatetime. The datetime object to which you want to compare the lcDatetime object. |
Units |
Long. The units to compare. Units are in the order listed in the constructor: Year, Month, Day, Hour, Minute, Second, Hundredth, Zone, DST. Use the following constants: |
LCDTUNIT_YEAR -- Year units. |
|
LCDTUNIT_MONTH -- Month units. |
|
LCDTUNIT_DAY -- Day units. |
|
LCDTUNIT_WEEKDAY -- Weekday units. |
|
LCDTUNIT_HOUR -- Hour units. |
|
LCDTUNIT_MINUTE -- Minute units. |
|
LCDTUNIT_SECOND -- Second units. |
|
LCDTUNIT_HUNDREDTH -- Hundredth of second units. |
|
LCDTUNIT_ZONE -- Time zone units. |
Return Value
Value |
Description |
---|---|
difference |
The difference between the two LCDatetime objects, in the units specified. |
If the objects are incompatible for comparison (that is, if one contains only a date and one contains only a time), or if they are date-only values and you ask for a difference in units less than days, the value will be zero.
Example
Option Public
Uselsx "*lsxlc"
Sub Initialize
Dim Boston As New LCDateTime _
(1998, 1, 25, 08, 50, 00, 00, -5, True)
Dim Singapore As New LCDateTime _
(1998, 1, 27, 1, 10, 00, 00, 8, False)
Print "A flight taking off from Boston at 8:50am"
Print "and landing in Singapore at 1:10am"
Print "will take " & Singapore.GetDiff (Boston, LCDTUNIT_HOUR) & " hours."
End Sub
Example Output
A flight taking off from Boston at 8:50am and landing in Singapore at 1:10am will take 27 hours.