sql server中datetime的内部表示是什么?

存储在sql Server(2000和2005,如果不同)中的日期时间值的基础数据结构是什么?即到字节表示?

大概是您选择日期时间列时获得的认表示是特定于文化的值/可能会更改.也就是说,我们看不到的一些底层结构被格式化为YYYY-MM-DD HH:MM:SS.mmm.

我问的原因是我的部门普遍认为它存储在内存中的字面意思是YYYY-MM-DD HH:MM:SS.mmm但我确信情况并非如此.

解决方法

它是 stored as an 8 byte field,范围从1753-01-01到9999-12-31,精确到0.00333秒.

据说细节不透明,但我在网上找到的大多数资源(1),(2)都说明如下:

The first 4 bytes store the number of days since sql Server’s epoch (1st Jan 1900) and that the second 4 bytes stores the number of ticks after midnight,where a “tick” is 3.3 milliseconds.

前四个字节是有符号的(可以是正数或负数),这解释了为什么可以表示早于时期的日期.

相关文章

SELECT a.*,b.dp_name,c.pa_name,fm_name=(CASE WHEN a.fm_n...
if not exists(select name from syscolumns where name=&am...
select a.*,pano=a.pa_no,b.pa_name,f.dp_name,e.fw_state_n...
要在 SQL Server 2019 中设置定时自动重启,可以使用 Window...
您收到的错误消息表明数据库 'EastRiver' 的...
首先我需要查询出需要使用SQL Server Profiler跟踪的数据库标...