An item of type INTERVAL is a series of one to twenty-one single-byte numeric digits that reflect an interval, which is the numeric difference between two points in time. The meaning of each digit is determined by the mask that you specify when declaring the item.
An interval can be positive (as when 1980 is subtracted from 2005) or negative (as when 2005 is subtracted from 1980), and at the beginning of the item is an extra byte that is not reflected in the mask. If an item of type INTERVAL is in a record, you must account for that extra byte when calculating the length of the record as well as the length of the superior item, if any.
In either case, each character in the mask represents a digit. In the month-span format, for example, the set of y's indicate how many years are in the item. If you only need three digits to represent the number of years, specify yyy in the mask. If you need the maximum number of digits (nine) to represent the number of years, specify yyyyyyyyy.
In a given mask, the first character may be used as many as nine times (unless otherwise stated); but the number of each subsequent kind of character is restricted further.
The default mask is yyyyMM.
yyyyyyMM yyyyyy MM ddHHmmssffffff HHmmssff mmss HHmm
// NOT valid ddmmssffffff HHssff
// 100 years, 2 months; the 4E means the value is positive 4E F0 F1 F0 F0 F0 F2 // 100 years, 2 months; the 60 means the value is negative 60 F0 F1 F0 F0 F0 F2
The internal hexadecimal representation of an example value is as follows if the default mask (yyyyMM) is in effect and if the item is on a workstation environment like Windows® 2000, which uses ASCII:
// 100 years, 2 months; the 2B means the value is positive 2B 30 31 30 30 30 32 // 100 years, 2 months; the 2D means the value is negative 2D 30 31 30 30 30 32
An item of type INTERVAL is strongly typed, so you cannot compare an item of this type with an item of any other type; nor can you assign an item of any other type to or from an item of this type.
Finally, an item of type INTERVAL cannot receive data from or provide data to a relational database.