GreenMachine
In Runtime
- Messages
- 285
Hi! I'm having trouble understanding how the DATE data type storage is 3 bytes in SQL Server.
The DATE data type stores only date values with a range of 0001-01-01 through 9999-12-31 and without hyphens. Therefore the possible range is between 00010101 and 99991231.
That being the case what am I missing here?
1 Byte = 2^8 = 256 (2^8-1= 255)
3 Bytes = 2^24 = 16,777,216 = Largest value stored in 3 bytes
The date 99991231 in binary = 101111101011011111010111111 = 27 BITS
Shouldn't the storage required be 4 Bytes?
The DATE data type stores only date values with a range of 0001-01-01 through 9999-12-31 and without hyphens. Therefore the possible range is between 00010101 and 99991231.
That being the case what am I missing here?
1 Byte = 2^8 = 256 (2^8-1= 255)
3 Bytes = 2^24 = 16,777,216 = Largest value stored in 3 bytes
The date 99991231 in binary = 101111101011011111010111111 = 27 BITS
Shouldn't the storage required be 4 Bytes?