SQL Language (MOSC)

MOSC Banner

add_months function bugged for the last day of month?

edited Feb 21, 2014 12:17PM in SQL Language (MOSC) 3 commentsAnswered ✓

Hi,

i have a wired behavior of the add_months function.

My current sysdate is 21 february, so +7 days is 28. february or last day of month. Adding one or two month to this date i would expect getting 28. March/April, but i actually get 31. March or 30 April!

select sysdate+6 from dual; -> 27.2

select sysdate+7 from dual; -> 28.2

select add_months(sysdate+6,1) from dual; -> 27.3

select add_months(sysdate+7,1) from dual; -> 31.3

select add_months(sysdate+7,2) from dual; -> 30.4

Shouldn't it return 28.3 and 28.4 by adding one month?

Regards

Thomas

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center