8.4.15 GetTimeCount (calculate the difference between times)
- Purpose
-
Calculates the difference between two specified times.
- Syntax
GetTimeCount (StartTime, EndTime [, UnitofTime])
- Arguments
-
- StartTime
-
Write the time from which to start the count in hh:mm:ss format.
If an invalid value is specified for hh, an error occurs. However, if an invalid value is specified for mm or ss, no error occurs. Instead, the GetTimeCount command replaces the specified time with the equivalent valid time.
For example, if 19:00:65 (a nonexistent time) were specified, the GetTimeCount command would replace the specified time with the valid time 19:01:05.
- EndTime
-
Write the time at which to end the count in hh:mm:ss format.
If an invalid value is specified for mm or ss, the GetTimeCount command replaces the specified time with the equivalent valid time.
- UnitofTime
-
Specify the units in which to calculate the elapsed time as one of the following values:
Value
Meaning
HourU
Get the number of elapsed hours.
For example, if the start time is 9:00:00 and the end time is 10:00:00, the calculation result will be 1. If the end time is 9:59:59, the calculation result will be 0.
MinuteU
Get the number of elapsed minutes.
For example, if the start time is 9:10:00 and the end time is 9:11:00, the calculation result will be 1. If the end time is 9:10:59, the calculation result will be 0.
SecondU
Get the number of elapsed seconds.
This value is optional. If you omit this value, SecondU is assumed.
- Description
-
The GetTimeCount command calculates the difference between two specified times, and returns the elapsed time as the command execution result. If the time specified in StartTime is later than the time specified in EndTime, a negative value is returned.
- Example
' Calculate the elapsed time from 9:10:30 to 10:09:20 ' in hours, minutes, and seconds. Dim time1, time2, hBuff, mBuff, sBuff time1 = "9:10:30" time2 = "10:09:20" ' The following code stores 0 in hBuff, 58 in mBuff, ' and 3530 in sBuff. hBuff = GetTimeCount (time1, time2, HourU) mBuff = GetTimeCount (time1, time2, MinuteU) sBuff = GetTimeCount (time1, time2, SecondU)
- JP1/Script version
-
Supported from JP1/Script 05-20.