DIFF_TIME

Use the DIFF_DATE 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

Examples

These examples calculate the difference between two times, and print the result in the activation report. The examples include the resulting line in the activation report.

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.

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

Because of the special term, the hours and seconds in the result are automatically 00.

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. The DIFF_TIME script function is called with the script variables. 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:

seealso

Script Date and Time Functions

Date, Time and Period Formats in Scripts