What is Difference between OADD_MONTHS and ADD_MONTHS

Database
N/A

What is Difference between OADD_MONTHS and ADD_MONTHS

What is the difference between OADD_MONTHS AND ADD_MONTHS ?

 

SyntaxEditor Code Snippet

select OADD_MONTHS(date '2017-02-28',2) as col1, ADD_MONTHS(date  '2017-02-28',2) as col2

output:

col1 col2
2017-04-30 2017-04-28
 

TIA

Nitin

2 REPLIES
Teradata Employee

Re: What is Difference between OADD_MONTHS and ADD_MONTHS

OADD_MONTHS is a function similar to ADD_MONTHS. The difference is that if a month is added to an end-of-month date with OADD_MONTHS, the function always returns an end-of-month date.


Examples

SELECT ADD_MONTHS (DATE '2016-02-29', 1);

ADD_MONTHS(2016-02-29, 1)
-------------------------
               2016-03-29


SELECT OADD_MONTHS (DATE '2016-02-29', 1);

OADD_MONTHS(2016-02-29, 1)
-------------------------
               2016-03-31

Teradata Employee

Re: What is Difference between OADD_MONTHS and ADD_MONTHS

Also, OAdd_Months is compatible with the Oracle Add_Months function.