Home > Database > Mysql Tutorial > sql 中smalldatetime和datetime 分析

sql 中smalldatetime和datetime 分析

WBOY
Release: 2016-06-07 17:49:21
Original
2106 people have browsed it

sql 中smalldatetime和datetime 分析 有需要的机友可参考一下。

1:日期范围上

smalldatetime的有效时间范围1900/1/1~2079/6/6
datetime的有效时间范围1753/1/1~9999/12/31

2:精准度上

smalldatetime只精准到分,而datetime则可精准到3位的毫秒。

3:存储空间上

smalldatetime占用4个字节,前2个字节存储base date(1900年1月1日)之后的天数。后2个字节存储午夜后的分钟数。

datetime占用8个字节,前4个字节存储base date(即1900年1月1日)之前或之后的天数,后4个字节存储午夜后的毫秒数

示例 调整后的示例
01/01/98 23:59:59.999 1998-01-02 00:00:00.000
01/01/98 23:59:59.995,
01/01/98 23:59:59.996,
01/01/98 23:59:59.997, 或
01/01/98 23:59:59.998
1998-01-01 23:59:59.997
01/01/98 23:59:59.992,
01/01/98 23:59:59.993,
01/01/98 23:59:59.994
1998-01-01 23:59:59.993
01/01/98 23:59:59.990 或
01/01/98 23:59:59.991
1998-01-01 23:59:59.990
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template