gpt4 book ai didi

sql-server - 1/1/1753 在 SQL Server 中有何意义?

转载 作者:行者123 更新时间:2023-12-01 16:16:18 25 4
gpt4 key购买 nike

为什么是 1753?他们对1752有什么看法?我的曾曾曾曾曾曾祖父会非常生气。

最佳答案

决定使用 1753 年 1 月 1 日 (1753-01-01) 作为 SQL Server 中日期时间的最小日期值可追溯到其 Sybase origins .

这个日期本身的意义可以归功于这个人。

Philip Stanhope, 4th Earl of Chesterfield

菲利普·斯坦霍普,第四代切斯特菲尔德伯爵。谁驾驶了Calendar (New Style) Act 1750通过英国议会。该法案规定英国及其当时的殖民地采用公历。

有一些missing days (internet archive link)在英国历法1752年的时候,终于对儒略历进行了调整。 1752年9月3日至1752年9月13日失利。

卡伦·德莱尼 explained这样选择

So, with 12 days lost, how can you compute dates? For example, how can you compute the number of days between October 12, 1492, and July 4, 1776? Do you include those missing 12 days? To avoid having to solve this problem, the original Sybase SQL Server developers decided not to allow dates before 1753. You can store earlier dates by using character fields, but you can't use any datetime functions with the earlier dates that you store in character fields.

1753 的选择确实看起来有点英国中心主义,但是 many catholic countries在英国实现之前,欧洲已经使用该日历 170 年(最初由于反对而推迟 by the church )。相反,许多国家直到很久以后(即 1918 年俄罗斯)才改革其日历。事实上,1917 年十月革命于公历 11 月 7 日开始。

Joe's answer 中提到的 datetime 和新的 datetime2 数据类型不要试图考虑这些本地差异,而只需使用公历。

因此,datetime2的范围更大

SELECT CONVERT(VARCHAR, DATEADD(DAY,-5,CAST('1752-09-13' AS DATETIME2)),100)

返回

Sep  8 1752 12:00AM

datetime2 数据类型的最后一点是它使用 proleptic Gregorian calendar向后预测到它实际发明之前的时间,因此在处理历史日期方面用途有限。

这与其他软件实现形成对比,例如 Java Gregorian Calendar类默认遵循儒略历,直到 1582 年 10 月 4 日为止的日期,然后跳转到新公历中的 1582 年 10 月 15 日。它正确处理该日期之前闰年的儒略模型和该日期之后的公历模型。调用者可以通过调用setGregorianChange()来更改切换日期。

一篇相当有趣的文章,讨论了采用日历的一些更多特性 can be found here .

关于sql-server - 1/1/1753 在 SQL Server 中有何意义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3310569/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com