You are here: Function Reference > Alphabetical Listing > D > DiffTime

DiffTime

Use this function to calculate the difference in time between two times. The system returns a signed (positive or negative) value, given in seconds.

Syntax

DiffTime (Time1, Format1, Time2, Format2)

Parameter

Description

Time1

Enter a time string. The system assumes this time string is in the format specified by the Format1 parameter. The default is the current time.

Format1

Enter a time format string that describes the Time1 parameter. The default is time format 1 (HH:MM:SS).

Time2

Enter a time string. The system assumes this time string is in the format specified by the Format2 parameter. The default is the current time.

Format2

Enter a time format string that describes the Time2 parameter. The default is time format 1.

The system returns a positive value if Time1 is earlier than Time2. The result is negative if Time2 is earlier than Time1.

Example

Here is an example:

(Assume the current time is 4:06:50 pm.)

Function

Result

Explanation

DiffTime

("4:06:40PM", 2)

+10

The second parameter defaults to the current time. The resulting difference in time is +10 seconds.

See also