您如何获得 Oracle 中的最大可能日期?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/687510/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 01:47:23  来源:igfitidea点击:

How do you obtain the maximum possible date in Oracle?

oraclefunctiondatemax

提问by Glenn Wark

Is there a function built into Oracle that will return the highest possible date that may be inserted into a date field?

Oracle 中是否有一个函数可以返回可能插入到日期字段中的最高日期?

回答by Quassnoi

SELECT  TO_DATE('31.12.9999 23:59:59', 'dd.mm.yyyy hh24:mi:ss')
FROM    dual

Note that minimal date is much more simple:

请注意,最小日期要简单得多:

SELECT  TO_DATE(1, 'J')
FROM    dual

回答by Angelo Marcotullio

From the 11g docs:

来自 11g 文档:

Oracle Database can store dates in the Julian era, ranging from January 1, 4712 BCE through December 31, 9999 CE (Common Era, or 'AD').

Oracle 数据库可以存储儒略时代的日期,范围从公元前 4712 年 1 月 1 日到公元 9999 年 12 月 31 日(共同时代,或“公元”)。

http://download.oracle.com/docs/cd/B28359_01/server.111/b28318/datatype.htm#i1847

http://download.oracle.com/docs/cd/B28359_01/server.111/b28318/datatype.htm#i1847

回答by FerranB

Another ways, just for fun:

另一种方式,只是为了好玩:

SELECT to_date(5373484, 'J') + (1 - 1/24/60/60)
  FROM dual;

SELECT date '9999-12-31' + (1 - 1/24/60/60) 
  FROM dual;

回答by Andrew Hare

I do not know of a function but according to this article:

我不知道一个功能,但根据这篇文章

Oracle 7:from January 1, 4712 BC to December 31, 4712 AD.
Oracle 8:from January 1, 4712 BC to December 31, 9999 AD.
Oracle 9:from January 1, 4712 BC to December 31, 9999 AD.
PL/SQL:from January 1, 4712 BC to December 31, 9999 AD.

甲骨文 7:从公元前 4712 年 1 月 1 日到公元 4712 年 12 月 31 日。
甲骨文 8:从公元前 4712 年 1 月 1 日到公元 9999 年 12 月 31 日。
甲骨文 9:从公元前 4712 年 1 月 1 日到公元 9999 年 12 月 31 日。
PL/SQL:从公元前 4712 年 1 月 1 日到公元 9999 年 12 月 31 日。

回答by TonyP

In Julian format (JDDD) the max Oracle date is 2086307365.

在 Julian 格式 (JDDD) 中,最大 Oracle 日期为 2086307365。