At 10:04 -0500 1/8/05, Frank Bax wrote:
At 06:00 AM 1/8/05, Ehud Shapira wrote:
I don't understand why DATETIME takes 8 bytes. It's just a waste,
since DATE+TIME take 6 bytes. And in fact, while DATE and TIME are
each rounded up to bytes on its own, a combined DATETIME should
only take 5 bytes:
14 bits for year
04 bits for month
05 bits for day
05 bits for hour
06 bits for minutes
06 bits for seconds
---
40 bits
datetime is "displayed" as YYYY-MM-DD HH:MM:SS - it is *not* stored
that way. It is stored as a *nix timestamp - an integer number of
seconds since 1970-01-01 00:00:00. A 4-byte integer field has
historically been used on *nix systems for this purpose, but this
has an upper limit of 2038. A larger *nix timestamp is now used to
avoid the equivalent of Y2K in 2038. The 8-byte *nix timestamp
accommodates micro-seconds.
No, it's the TIMESTAMP type that's stored as second since the epoch.
DATETIME is stored like this:
Part 1 is a 32-bit integer containing year*10000 + month*100 + day.
Part 2 is a 32-bit integer containing hour*10000 + minute*100 + second.
--
Paul DuBois, MySQL Documentation Team
Madison, Wisconsin, USA
MySQL AB, www.mysql.com
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]