# question

## 3 Bytes for DATE how?

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 Greatest possible 3 Byte value: 16777216 Max DATE data type 3 Byte value: 99991231 Shouldn't storage require more than 3 Bytes?

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

·
The date data-type is in effect the number of days since the so-called epoch date / day zero, rather than an integer-type representation of the date such as you describe.. The [documentation][1] states the date range stored is from 0001-01-01 to 9999-12-31; approximately 3,652,500 days. Year 10k problem, anybody? [1]: https://docs.microsoft.com/en-us/sql/t-sql/data-types/date-transact-sql

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Glad I won't be around :) 2K was enough lol
1 Like 1 ·
Y2K was not good for the company I worked at at the time - we were a small consultancy that was focused on implementing new business process / document management / imaging systems, and didn't have any clients with non-y2k compliant systems (at least, not ones we had put in), so no nice maintenance / upgrade contract work. The company shrank by about 25%-30% during 1999-early2000.
0 Likes 0 ·