}From: tero@clinet.fi (Tero Ylih{rsil{)
}Subject: Help: DATETIME ?
}Date: 2 Nov 1994 22:13:42 GMT
}X-Informix-List-Id: <news.9606>
}I need to know how "DATETIME year to second" is stored ?
}The product I am using is INFORMIX-SE 5.01 on SCO UNIX rel.3.2v4.2.
}create table dtest (datetime DATETIME year to second);
}insert into dtest value ("0001-01-01 05:07:00");
}insert into dtest value ("1994-02-01 01:02:00");
}Here is the problem:
}If I use 'hd' or 'od' to check what was stored on the disk:
} hex dec
}c6 01 01 01 05 07 00 00 198 01 01 01 05 07 00 00
}c7 13 5e 02 01 01 02 00 199 19 94 02 01 01 02 00
}I can't figure out where those c6 and c7 come from and what do they mean?
}In the first example, the year requires only 2 bytes (c6 01), and in the
}second the year requires 3 bytes (c7 13 5e).
}Informix Guide to SQL says that YEAR to SECOND qualifier requires a total of
}14 digits(4 for year,2 for month,2 for day,2 for hour, 2 for minute, and 2
}for second). This data value requires 8 bytes (14/2+1) of storage, which seems
}to be correct.
As you'd be able to tell if you looked in the <datetime.h> structures, the
data is stored in a decimal structure (dec_t defined in <decimal.h>).
If you ignore the first byte, the decimal dump is trivial to read -- one of
the nice things about datetime data. The 19 and 94 bytes store the year
1994, the first 02 byte stores the month, the first 01 byte the hour, the
second the minute, and the second 02 byte the second. Fractions would also
appear legibly.
The first byte of the decimal structure contains the sign and exponent
information. The first bit set indicates that it is a positive number (0
for negative), the 6 indicates that there are 6 base-100 digits before the
decimal point, and the 0x40 that isn't yet accounted for is the bias-64
used.
Yours,
Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>