Tonight there is going to be a leap second added to the clocks and there will be 61 seconds in the last minute of the last hour of the day.
2015-06-30 23:59:60
However, Oracle only supports up to 60 seconds in a minute:
TO_DATE( '2015-06-30 23:59:60', 'YYYY-MM-DD HH24:MI:SS' )
Errors with:
ORA-01852: seconds must be between 0 and 59
and
SELECT TO_DATE( '2015-06-30 23:59:59', 'YYYY-MM-DD HH24:MI:SS' ) + INTERVAL '1' SECOND AS Incr_Second_Before,
TO_DATE( '2015-07-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS' ) - INTERVAL '1' SECOND AS Decr_Second_After
FROM DUAL
Gives the output:
| INCR_SECOND_BEFORE | DECR_SECOND_AFTER |
|------------------------|------------------------|
| July, 01 2015 00:00:00 | June, 30 2015 23:59:59 |
Is there any way to handle a leap second in Oracle?
A stratum 4 ntp server may get the leap indicator over an hour after the start of the day. When a Linux ntpd gets the leap indicator it uses adjtimex (2) to tell the kernel that a leap second is going to be inserted (or deleted) at midnight UTC. The NTP daemon is not responsible for actually handling the leap second, it defers that to the kernel.
We will always have at least three months' notice of a leap second but they are essentially unpredictable because the earth wobbles. The last leap second was at the end of June 2012 and the next one is at the end of June 2015. So far we haven’t had any short days, but it’s possible.
The last leap second was at the end of June 2012 and the next one is at the end of June 2015. So far we haven’t had any short days, but it’s possible.
Oracle LAG 1 Introduction to Oracle LAG () function. Oracle LAG () is an analytic function that allows you to access the row at a given offset prior to the current row without ... 2 Oracle LAG () function examples. ... 3 A) Using Oracle LEAD () function over a result set example. ... 4 B) Using Oracle LAG () function over partitions example. ...
From MOS-
Insert leap seconds into a timestamp column fails with ORA-01852 (Doc ID 1553906.1)
APPLIES TO:
Oracle Database - Enterprise Edition - Version 8.1.7.4 and later
Oracle Database - Standard Edition - Version 8.1.7.4 and later
Information in this document applies to any platform.
SYMPTOMS:
An attempt to insert leap seconds into a timestamp column, fails with: ORA-01852: seconds must be between 0 and 59
CAUSE
It is not possible to store >59 sec value in a date or timestamp datatype
SOLUTION
To workaround this issue, the leap second record can be stored in a varchar2 datatype instead e.g.
SQL> create table test (val number, t varchar2(30));
Table created.
SQL> insert into test values(123, '2012-06-30T23:59:60.000000Z');
1 row created.
Not the best solution, but the only solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With