Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you obtain the maximum possible date in Oracle?

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

like image 574
Glenn Wark Avatar asked Mar 26 '09 20:03

Glenn Wark


People also ask

What is the minimum date in Oracle?

The minimum valid date for an OracleDateTime structure is 1/1/0001 00:00:00. However, Oracle supports dates as early as January 1, 4712 BC.

What does Max function do in Oracle?

MAX is an aggregate function that evaluates the maximum of an expression over a set of rows (see Aggregates (set functions)). MAX is allowed only on expressions that evaluate to built-in data types (including CHAR, VARCHAR, DATE, TIME, CHAR FOR BIT DATA, etc.).

What is the range of dates valid in Oracle SQL?

Valid DATE Values. A valid DATE value must fall between January 1, 1000, and December 31, 9999. It must conform to one of three styles: numeric, packed numeric, or month name. You can mix these styles throughout a session.


3 Answers

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 
like image 77
Quassnoi Avatar answered Sep 17 '22 20:09

Quassnoi


From the 11g docs:

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

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

like image 30
Angelo Marcotullio Avatar answered Sep 20 '22 20:09

Angelo Marcotullio


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.

like image 44
Andrew Hare Avatar answered Sep 19 '22 20:09

Andrew Hare