DiffDateTime Function

Action

Calculates the difference between two DATETIME values.

Syntax

iDaysDiff = DiffDateTime (DateTime1, DateTime2 [,iHours, iMinutes, iSeconds, iMicrosecs])
Variable Description
iDaysDiff The returned difference in days resulting from subtracting DateTime2 from DateTime1. INTEGER.
DateTime1 The DATETIME value from which DateTime2 is subtracted. DATETIME.
DateTime2 The DATETIME value to be subtracted from DateTime1. DATETIME.
iHours Optional. The Hours component of the difference between DateTime1 and DateTime2. out INTEGER.
iMinutes Optional. The Minutes component of the difference between DateTime1 and DateTime2. out INTEGER.
iSeconds Optional. The Seconds component of the difference between DateTime1 and DateTime2. out INTEGER.
iMicrosecs Optional. The Microseconds component of the difference between DateTime1 and DateTime2. out INTEGER.

Notes

The return value is just the Days component of the difference between the DATETIME values. The hours, minutes, seconds, and microseconds differences are returned in optional out arguments.

To skip over an optional argument, use NULL as a placeholder.

You can use the optional out arguments to specify variables that receive the corresponding field from the calculated difference. In the first example below, the function returns difference values for days, hours, minutes, and seconds-ignoring microseconds. In the second example, the only values of interest are in the minutes, seconds, and microseconds fields of the difference and those are the only values returned.

Examples

iDaysDiff = DiffDateTime (CurrentDate, LastDate, iHoursDiff, 
iMinsDiff, iSecsDiff) 
DiffDateTime (CurrentDate, LastDate, NULL,
iMinsDiff, iSecsDiff, iMicrosecs)