informix
INFORMIX-ESQL/C Programmer's Manual
ESQL/C Function Library

dtsub()

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

Syntax

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 Codes

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

Example

The demo directory contains this sample program in the file dtsub.ec. The program performs datetime subtraction that returns equivalent interval results in the range of year to month and month to month and attempts to return an interval result in the range day to hour.

Output


INFORMIX-ESQL/C Programmer's Manual, Version 9.21
Copyright © 1999, Informix Software, Inc. All rights reserved