开发者

Has date type changed in SQL Server 2008?

I am confused reading statements in "Why is 1899-12-30 the zero date in Access / SQL Server instead of 12/31?"

Was there date type in SQL Server before 2008 version? I cannot find.

In SQL Server 2008 zero date is 0001-01-01. Were there any date type before (in previ开发者_开发百科ous SQL Server versions) how is it backward compatible?


No. Prior to SQL Server 2008, there was only the datetime and smalldatetime types.

Data type...............Range..................................................................Accuracy
datetime..................January 1, 1753, through December 31, 9999.....3.33 milliseconds

smalldatetime..........January 1, 1900, through June 6, 2079............... 1 minute

Please see: Date and Time Data in SQL Server 2008, specifically the bit that says "Date/Time Data Types Introduced in SQL Server 2008"


In SQL Server datetime datatype the minimum date that can be stored is 1 Jan 1753.

However the datetimes are stored as numeric offsets to a base date of 1900-01-01 00:00:00.000

SELECT CAST(-0.25 AS DATETIME) /*1899-12-31 18:00:00.000*/
SELECT CAST(0 AS DATETIME) /*1900-01-01 00:00:00.000*/
SELECT CAST(0.25 AS DATETIME) /*1900-01-01 06:00:00.000*/

1899-12-30 has no significance in SQL Server.

SELECT CAST(CAST('1899-12-30' AS DATETIME) AS FLOAT) /*Returns -2*/
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜