TMF Application Programmer's Guide (G06.24+)
TMF ARLIB2 Audit-Reading Procedures
HP NonStop TMF Application Programmer’s Guide—522419-004
5-18
DATETIME and INTERVAL Fields
DATETIME and INTERVAL Fields
DATETIME and INTERVAL fields in NonStop SQL/MP tables store time-related
information using varying units. DATETIME fields contain a value that designates a
point in time. INTERVAL fields contain a value that represents a time interval or
duration. Information is represented on disk depending on how the field is declared.
A DATETIME field stores values for a logically contiguous subset of the following
subfields:
The length of a DATETIME field is determined by its declaration. For example, a field
declared as DATETIME HOUR TO FRACTION(1) will be of length 1 + 1 + 1 + 4 = 5
bytes.
The DATE, TIME, and TIMESTAMP types are special cases of DATETIME:
An INTERVAL field stores an integer whose units are those of the smallest subfield in
its declaration. For example, a field of the type INTERVAL HOUR(1000) TO SECOND
will contain an integer number of seconds while a field of the type INTERVAL MINUTE
TO FRACTION(3) will contain an integer number of microseconds.
The length of an INTERVAL field is determined by the space required to represent the
largest value that can be accommodated by the declared field and is either 2, 4, or 8
bytes (that is, the field contains a 16-bit, 32-bit, or 64-bit integer).
Null Fields
A field in a NonStop SQL/MP table that can be set to a null value consists of a 1-word
(2-byte) null indicator followed by the normal field itself. If the null indicator is set, then
the value in the field is undefined (except that VARCHAR fields retain their length
word). If the null indicator is not set, then the value in the field is valid. The value -1 in
the null indicator specifies that the field is null, while the value 0 specifies that the field
is not null.
Subfield Value Range Storage
YEAR 1 to 9999 2 bytes
MONTH of year 1 to 12 1 byte
DAY of month 1 to 31 1 byte
HOUR of day 0 to 23 1 byte
MINUTE of hour 0 to 59 1 byte
SECOND of minute 1 to 59 1 byte
FRACTION of second 0 to 9(n)* 4 bytes
* n is the number of decimal digits of precision and is in the range 1 to 6. For example, FRACTION(3) has the
range of values 0 to 999, which represent .000 to .999 seconds.
DATE is equivalent to DATETIME YEAR TO DAY
TIME is equivalent to DATETIME HOUR TO SECOND
TIMESTAMP is equivalent to DATETIME YEAR TO FRACTION(3)