datetime与smalldatetime之间的区别小结
1、时间范围的差别:
smalldatetime的有效时间范围1900/1/1~2079/6/6
datetime的有效时间范围1753/1/1~9999/12/31
所以一般我都会用smalldatetime。
SQL Server中,smalldatetime只能精确到分钟,而datatime可以精确到3%秒(3.33毫秒)。
smalldatetime占用4个字节
datetime占用8个字节
smalldatetime的有效时间范围1900/1/1~2079/6/6
datetime的有效时间范围1753/1/1~9999/12/31
所以一般我都会用smalldatetime。
2、精准的差别:
smalldatetime只精准到分
datetime则可精准到3.33毫秒。
SQL Server中,smalldatetime只能精确到分钟,而datatime可以精确到3%秒(3.33毫秒)。
smalldatetime占用4个字节
datetime占用8个字节
由于datetime的精度是3%秒,这就涉及到小数,毫秒之前可以是冒号,也可以是小数点。
使用冒号时表示的意义同时分秒间隔,11:11:11:21表示021毫秒,前面的0省略
而小数点表示的意义同数学上的小数点,如11:11:11.21表示210毫秒,省略的是后面的0。