Apparently, there are ways to actually enter such dates into Oracle database though the usual ways by SQLPlus is not one of them. Be it as it may, this post is not about that. It is about a quirk (May I call it Oracle bug?) at least in 19c.
The values of D3 and D5 are no valid dates. There is no year 0. D3_1 shows that the actual calculation is not that wrong.
The code, so you can reproduce easier.
select to_char(to_date('-0001-12-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss'), 'syyyy-mm-dd hh24:mi:ss') as d1
,to_char(to_date(' 0001-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') - 1/24/60/60, 'syyyy-mm-dd hh24:mi:ss') as d2
,to_char(add_months(to_date(' 0001-01-01 23:59:59', 'syyyy-mm-dd hh24:mi:ss'), -1), 'syyyy-mm-dd hh24:mi:ss') as d3
,add_months(to_date(' 0001-01-01 23:59:59', 'syyyy-mm-dd hh24:mi:ss'), -1) as d3_1
,to_char(to_date(' 0001-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') - 1, 'syyyy-mm-dd hh24:mi:ss') as d4
,to_char(add_months(to_date(' 0001-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss'), -1), 'syyyy-mm-dd hh24:mi:ss') as d5
,to_char(to_date('-0001-12-01 23:59:59', 'syyyy-mm-dd hh24:mi:ss') - 1/24/60/60, 'syyyy-mm-dd hh24:mi:ss') as d6
,to_char(add_months(to_date(' 0001-01-01 23:59:59', 'syyyy-mm-dd hh24:mi:ss'), -2), 'syyyy-mm-dd hh24:mi:ss') as d7
from dual;



Keine Kommentare:
Kommentar veröffentlichen