| 01-jan-4713? [message #13711] |
Sun, 25 July 2004 03:33  |
sancha
Messages: 31 Registered: October 2003
|
Member |
|
|
One hypothetical question
we know that the range of DATE variable is 01-JAN-4712 BC TO 31-DEC-4712 AD.
When the clock ticks, 01-Jan-4713 AD - what will happen?
Is there any provision to handle the same?
bfn
|
|
|
|
| Re: 01-jan-4713? [message #13712 is a reply to message #13711] |
Sun, 25 July 2004 04:36   |
Frank Naude
Messages: 4596 Registered: April 1998
|
Senior Member |
|
|
Hi,
Oracle will have to introduce a new DATE data type that can handle dates after 31-DEC-4712; or somehow modify the current DATE type to handle bigger dates. Luckily they still have some time left:
SQL> select to_date('31-DEC-4712') - sysdate "Days left",
2 months_between('31-DEC-4712', sysdate) "Months left",
3 months_between('31-DEC-4712', sysdate)/12 "Years left"
4 from dual;
Days left Months left Years left
---------- ----------- ----------
989234.387 32501.1738 2708.43115
BTW: At the rate we currently abuse and pollute our environment, mankind will probably be extinct well before 31-DEC-4712. If we by accident do make it, it would certainly not be on mother earth.
Best regards.
Frank
|
|
|
|
|
|
| Re: 01-jan-4713? [message #13719 is a reply to message #13713] |
Sun, 25 July 2004 13:55   |
William Robertson
Messages: 1643 Registered: August 2003 Location: London, UK
|
Senior Member |
|
|
Actually we have 5,286 years longer than you think to find a solution:
SQL*Plus: Release 9.2.0.1.0 - Developer's Release on Sun Jul 25 22:06:24 2004
SQL> SELECT TO_DATE('31-DEC-4712','DD-MON-YYYY') +1 FROM dual;
TO_DATE('31
-----------
01-JAN-4713
1 row selected.
SQL> SELECT DATE '9999-12-31' FROM dual;
DATE'9999-1
-----------
31-DEC-9999
1 row selected.
SQL> SELECT DATE '9999-12-31' +1 FROM dual
SELECT DATE '9999-12-31' +1 FROM dual
*
ERROR at line 1:
ORA-01841: (full) year must be between -4713 and +9999, and not be 0
Perhaps in the 7,995 years until then, Oracle will have found a way to store 5-digit years, and while we're at it, implemented private methods in object types and fixed DBMS_OUTPUT.
Maybe by then we will also have learned the lessons of 78 two-digit year crises.
|
|
|
|
| Re: 01-jan-4713? [message #13724 is a reply to message #13719] |
Sun, 25 July 2004 22:01   |
Frank Naude
Messages: 4596 Registered: April 1998
|
Senior Member |
|
|
Hi,
Quite right, the Oracle DATE range is from January 1, 4712 BC to December 31, 9999 AD.
The 31-DEC-4712 limit was removed in Oracle 8.x already.
Best regards.
Frank
|
|
|
|
| Re: 01-jan-4713? [message #13731 is a reply to message #13712] |
Sun, 25 July 2004 23:44  |
Thomas G
Messages: 58 Registered: April 2003
|
Member |
|
|
Ahhhh, but you forget you are not just storing CURRENT dates in a database.
If we DO get extinct on 31-DEC-4712 or 31-DEC-9999 scientists will propably blame it on software that didn't allow them to predict farther into the future. ;-)
|
|
|
|