[ 
https://issues.apache.org/jira/browse/HIVE-9357?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14277700#comment-14277700
 ] 

Alexander Pivovarov commented on HIVE-9357:
-------------------------------------------

yes, Orcale "date +  interval N month" works different:
{code}
SELECT to_date('28-JAN-2014') + interval '1' month from dual;
2014-02-28
--add_month also returns 2014-02-28

SELECT to_date('29-JAN-2014') + interval '1' month from dual;
Error: ORA-01839: date not valid for month specified
--add_month returns 2014-02-28

SELECT to_date('28-FEB-2014') + interval '1' month from dual;
2014-03-28
--add_month returns 2014-03-31
{code}

So, it does not have any smart logic. it just increases month and checks if 
date is valid. if valid it returns new date. if not it throws error ORA-01839

> Create ADD_MONTHS UDF
> ---------------------
>
>                 Key: HIVE-9357
>                 URL: https://issues.apache.org/jira/browse/HIVE-9357
>             Project: Hive
>          Issue Type: Improvement
>          Components: UDF
>            Reporter: Alexander Pivovarov
>            Assignee: Alexander Pivovarov
>         Attachments: HIVE-9357.1.patch
>
>
> ADD_MONTHS adds a number of months to startdate: 
> add_months('2015-01-14', 1) = '2015-02-14'
> add_months('2015-01-31', 1) = '2015-02-28'
> add_months('2015-02-28', 2) = '2015-04-30'
> add_months('2015-02-28', 12) = '2016-02-29'



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to