The dtsub() function

The dtsub() function subtracts one datetime value from another. The result is an interval value.

Syntax

mint dtsub(d1, d2, inv)
   dtime_t *d1, *d2;
   intrvl_t *inv;
d1
A pointer to an initialized datetime variable.
d2
A pointer to an initialized datetime variable.
inv
A pointer to an interval variable to contain the result.

Usage

The dtsub() function subtracts the datetime value d2 from d1 and stores the interval result in inv. The result can be either a positive or a negative value. If necessary, the function extends d2 to match the qualifier for d1, before the subtraction.

Initialize the qualifier for inv with a value in either the year to month or day to fraction(5) classes. When d1 contains fields in the day to fraction class, the interval qualifier must also be in the day to fraction class.

Return values

0
The subtraction was successful.
<0
An error occurred while performing the subtraction.