Oracle 12c - add months to a date poses interesting case:
Issue: I need to move rows containing column renewal with certain date to future date
Later when I am done my work, I want to return those rows back to what they were before.
But in doing that I don't get original date for some records.
I have some rows with renewal date of Feb 28, 2016, and Feb 29,2016.
I move these rows by changing their renewal to future date like this:
select add_months( TO_DATE('28-Feb-2016','dd-Mon-yyyy'), 12*5 ) dt from dual;
select add_months( TO_DATE('29-Feb-2016','dd-Mon-yyyy'), 12*5 ) dt from dual;
when I have return the date back from '28-Feb-2021', I don't get 28Feb2016 anymore:
select add_months( TO_DATE('28-Feb-2021','dd-Mon-yyyy'), -12*5 ) dt from dual;
gives Feb 29, 2016.
How to correct this? :(