1, will the 2016-02-29 plus six months, according to the results of the 2016-08-29
2, 2016-08-31 and six months, according to the results of the 2017-03-03
Similarly other plus six months after the date of need is the law of according to the above 2 points,
Add_month tried to use function, but the results were shown as "2016-08-31", "2017-02-28", "
Excuse me, how can be shown as "2016-08-29", "2017-03-03" (a fellow masters can be taught to solve)
CodePudding user response:
What is your expected data rule?CodePudding user response:
SQL> The select add_months (to_date (' 2016-02-29 ', '- dd yyyy - mm), 6) + extract (day from the date' 2016-02-29 ') - extract (day from add_months (to_date (' 2016-02-29 ', '- dd yyyy - mm), 6)) from dual;ADD_MONTHS (TO_DATE (
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
2016-08-29 00:00:00
SQL> The select add_months (to_date (' 2016-08-31 ', '- dd yyyy - mm), 6) + extract (day from the date' 2016-08-31 ') - extract (day from add_months (to_date (' 2016-08-31 ', '- dd yyyy - mm), 6)) from dual;
ADD_MONTHS (TO_DATE (
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
2017-03-03 00:00:00