惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Hacker News: Ask HN
Hacker News: Ask HN
月光博客
月光博客
Martin Fowler
Martin Fowler
人人都是产品经理
人人都是产品经理
有赞技术团队
有赞技术团队
Hugging Face - Blog
Hugging Face - Blog
T
Tailwind CSS Blog
爱范儿
爱范儿
博客园_首页
Last Week in AI
Last Week in AI
N
Netflix TechBlog - Medium
NISL@THU
NISL@THU
H
Help Net Security
A
Arctic Wolf
K
Kaspersky official blog
Y
Y Combinator Blog
G
GRAHAM CLULEY
T
Threatpost
I
Intezer
Attack and Defense Labs
Attack and Defense Labs
Jina AI
Jina AI
Recent Announcements
Recent Announcements
D
Docker
博客园 - 聂微东
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
www.infosecurity-magazine.com
www.infosecurity-magazine.com
GbyAI
GbyAI
The Hacker News
The Hacker News
C
Cyber Attacks, Cyber Crime and Cyber Security
Help Net Security
Help Net Security
Microsoft Azure Blog
Microsoft Azure Blog
G
Google Developers Blog
F
Fortinet All Blogs
S
Security Affairs
Security Archives - TechRepublic
Security Archives - TechRepublic
量子位
AWS News Blog
AWS News Blog
Google DeepMind News
Google DeepMind News
罗磊的独立博客
V
Vulnerabilities – Threatpost
阮一峰的网络日志
阮一峰的网络日志
T
Tor Project blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
H
Hacker News: Front Page
Security Latest
Security Latest
The Cloudflare Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
M
MIT News - Artificial intelligence
B
Blog
云风的 BLOG
云风的 BLOG

博客园 - Rainbow.ding

SSRS 表达式 用户中心 - 博客园 DataTable的Distinct SQL Server 2005 - Default Trace (默认跟踪) 数据库设计范式的理解(转) 设置SQL2008报表匿名访问的方法 sqlserver 日期字段转换格式 数据库镜像 Sql Server格式化日期(转) 彼尔盖茨的十句话,绝对让你改变一生! 必须掌握的8个cmd 命令(转) 海量数据处理 (转) 软件开发者面试百问(转) 薪资谈判技巧 综述ASP.NET下的AJAX模式 水晶报表注册码 ASP.NET中传参一种简单加密与解密QueryString的方法 BI的相关名词 在外企必会的10个英文单词:
SQL SERVER 中的smalldatetime和datetime区别
Rainbow.ding · 2011-01-04 · via 博客园 - Rainbow.ding

smalldatetime不能到秒. 
不過它占的空間小.(4位) 
datetime(8位) 
而且兩者的時間範圍不一樣.   

datetime占8字节,精度3.33毫秒,时间从1753.1.1到9999.12.31 
smalldatetime占4字节,精度1分钟,时间从1900.1.1到2079.6.6
    
datetime 

Date and time data from January 1, 1753, to December 31, 9999, with an accuracy of three-hundredths of a second, or 3.33 milliseconds. 

smalldatetime 

Date and time data from January 1, 1900, through June 6, 2079, with an accuracy of one minute.

碰上了這件事,才學到教訓,一直以為smalldatetime和datetime的差別只是在於時間範圍:

smalldatetime的有效時間範圍1900/1/1~2079/6/6

datetime的有效時間範圍1753/1/1~9999/12/31

所以我判斷如果該值不用到太遠的日期範圍,就會使用smalldatetime。

但我忽略了更關鍵的差別,那就是smalldatetime只精準到分,而datetime則可精準到3.33毫秒。

因此,當我怎麼存,秒都是00後,才發現原來是smalldatetime惹的禍,待我將資料型別改成datetime後,秒的部份就可以正常儲存了。

*****************************************************************************************

SQL Server中,smalldatetime只能精确到分钟,而datatime可以精确到3%秒(3.33毫秒)。

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

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

由于datetime的精度是3%秒,这就涉及到小数,毫秒之前可以是冒号,也可以是小数点。使用冒号时表示的意义同时分秒间隔,11:11:11:21表示021毫秒,前面的0省略,而小数点表示的意义同数学上的小数点,如11:11:11.21表示210毫秒,省略的是后面的0。