DIFF_TIME

Use the DIFF_TIME script function to calculate the difference between two times. The script function lets you specify the format for the returned value.

Syntax

DIFF_TIME ([TimeFormat;]Time1, [TimeFormat;]Time2 [, OutputFormat])

Parameters

Parameter Description Format Default Value
Time1, Time2

Specify the times to calculate the difference between.

Note:

  • Time2 can be before or after Time1. The difference is always calculated by deducting the earlier time from the later time.
  • Specify the time format when you use a format other than HHMMSS. Separate the time format and the time with a semicircle (semicolon). For more information, see Date, Time and Period Formats in Scripts.
Script literal or script variable n.a.
OutputFormat (Optional) Time format for the returned value. Script literal or script variable HHMMSS

Return Codes

The DIFF_TIME function returns the calculated difference between two times as a string in the specified output format.

Examples

In the following example, the times use the default HHMMSS format, so the time formats do not need to be specified. The output format is not specified, so the difference is also returned in the default HHMMSS format.

: SET &DIFF# = DIFF_TIME ("230000""223000" )

: PRINT &DIFF#

Line in the activation report:

2019-03-28 12:56:06 - U00020408 003000

The following script uses a special term (MM) for one of the times, and specifies HH:MM as the output format. Because of the special term, the hours and seconds in the result are automatically 00.

: SET &DIFF# = DIFF_TIME ("HH:MM:SS;00:01:30""MM;11""HH:MM" )

: PRINT &DIFF#

Line in the activation report:

2019-03-28 13:00:31 - U00020408 00:09

In the following example, the times are assigned to script variables and passed to the script function. Since the times do not use the default time formats, the script must specify the time formats.

: SET &TIME1# = "00:00:00" 

: SET &TIME2# = "12:00:00"

 : SET &DIFF# = DIFF_TIME ("HH:MM:SS;&TIME1#"  "HH:MM:SS;&TIME2#" )

: PRINT &DIFF#

Line in the activation report:

2019-03-28 13:04:35 - U00020408 120000

See also: