Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
351 views
in Technique[技术] by (71.8m points)

date - add_months function strange behaviour in Oracle 19c

I've just bumped into very strange case for me. See:

select add_months(to_date('26.01.2021 01:04:00', 'DD.MM.YYYY HH24:MI:SS'), 500000) good from dual;
-- returns 3751-09-26 01:04:00

select add_months(to_date('26.01.2021 01:04:00', 'DD.MM.YYYY HH24:MI:SS'), 100000) bad from dual;
-- returns ORA-01841 (full) year must be between -4713 and +9999, and not be 0

Okay, let's check: 500000 months is about 41666 years which is already more than +9999 bound. Is it somehow cycling inside? As for 100000 months = 8333 years - it is inside of (-4713;+9999) interval but sum of 2021 year and 8333 years is not.

I'm a bit confused.

Oracle version is:

Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.7.0.0.0
question from:https://stackoverflow.com/questions/65905212/add-months-function-strange-behaviour-in-oracle-19c

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...