Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

DATETIME2 Internal Storage Structure

$
0
0

I propose the following:

DATETIME2 8 bytes (precision > 4) internal storage structure

o 1st byte: precision like 7

o middle 4 bytes: number of time units (smallest 100ns) since midnight

o last 3 bytes: number of days after the base date 0001-01-01

Is it correct? Thanks.

DECLARE @dt2 DATETIME2 = '00020101 00:00:00.0000009'
SELECT convert(binary(9), @dt2);
-- 0x0709000000006D0100

DECLARE @dt26 DATETIME2(6) = '00020101 00:00:00.000008'
SELECT convert(binary(9), @dt26);
-- 0x0608000000006D0100


Kalman Toth Database & OLAP Architect SELECT Video Tutorials 4 Hours
New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012




Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>