SQL Server 2008 里面 DateTime2 解决过去恐怖的 MinValue问题
2011-01-20 13:18
351 查看
从 SQL Server 2008起,微软老大引入了一个新数据类型 datetime2, 允许 数据库中时间的最小值增大到与.NET Framework的日期格式一样精确,虽然还是有点不同,但是已经基本能够解决我们以前存取日期格式的问题:
datetime2格式允许的时间范围是:"0001 / 01 / 01" through "9999 / 12 / 31" 即从c#中 DateTime.MinValue到 DateTime.MaxValue 的范围;
由于DateTime 为Null时返回值是按照 DateTime.MinValue来的,所以如果我们通过DateTime2来存储日期格式,就能够完美解决过去 "DateTime overflow " 的问题
同时MSDN也开始推荐用datetime2 来代替datetime - 既然微软老大也这么提倡了,那我们赶紧吧。。。
-----
The MSDN documentation for datetime
recommends using datetime2
. Here is their recommendation:
Use the time, date, datetime2 and
datetimeoffset data types for new
work. These types align with the SQL
Standard. They are more portable.
time, datetime2 and datetimeoffset
provide more seconds precision.
datetimeoffset provides time zone
support for globally deployed
applications.
datetime2 has larger date range, a larger default fractional
precision, and optional user-specified precision. Also depending on the
user-specified precision it may use less storage.
datetime2格式允许的时间范围是:"0001 / 01 / 01" through "9999 / 12 / 31" 即从c#中 DateTime.MinValue到 DateTime.MaxValue 的范围;
由于DateTime 为Null时返回值是按照 DateTime.MinValue来的,所以如果我们通过DateTime2来存储日期格式,就能够完美解决过去 "DateTime overflow " 的问题
同时MSDN也开始推荐用datetime2 来代替datetime - 既然微软老大也这么提倡了,那我们赶紧吧。。。
-----
The MSDN documentation for datetime
recommends using datetime2
. Here is their recommendation:
Use the time, date, datetime2 and
datetimeoffset data types for new
work. These types align with the SQL
Standard. They are more portable.
time, datetime2 and datetimeoffset
provide more seconds precision.
datetimeoffset provides time zone
support for globally deployed
applications.
datetime2 has larger date range, a larger default fractional
precision, and optional user-specified precision. Also depending on the
user-specified precision it may use less storage.
相关文章推荐
- SQL Server 2008 里面 DateTime2 解决过去恐怖的 MinValue问题
- SQL Server 2008 里面 DateTime2 解决过去恐怖的 MinValue问题
- SQL Server 2008 阻止保存要求重新创建表的更改问题的解决方法
- SQL Server 2008无法还原日志备份或差异备份的问题解决(转)
- 具体解决VS“滴答数必须介于 DateTime.MinValue.Ticks 和 DateTime.MaxValue.Ticks 之间”奇怪问题
- SQL Server 2008 安装过程中遇到“性能计数器注册表配置单元一致性”检查失败 问题的解决方法【已验证
- SQL Server 2008 安装过程中遇到“性能计数器注册表配置单元一致性”检查失败 问题的解决方法【已验证 】
- 关于sql server 2008安装闪退问题解决
- SQL Server 2008 R2 SSRS 安装配置后无法使用问题的解决方法
- win8上安装sql server (2008 and 2008 R2)存在兼容性问题怎么解决
- 解决无法安装SQL Server 2008 Management Studio Express的问题
- ArcSDE10 for Miscrosoft SQL Server 2008 Express 下载、安装以及碰到问题的解决
- SQL Server 2008 数据库---连接问题(网上搜解决)
- Sql server 2008数据库邮件发送问题解决日志
- SQL server 2008 安装问题解决 转
- SQL Server 2008 R2 超详细安装图文教程及问题解决(锐姿公司安装)
- sql server 2008手工修改表结构,表不能保存的问题与解决
- 解决SQL Server 2008 64位系统无法导入Access/Excel的问题 2012/08/01
- 【SQL 问题】试用版SQL Server 2008 R2 提示评估期已过,数据库不能访问解决办法
- 终于解决了在Visual Studio 2008 无法创建 Sql Server 数据库的问题