Oracle of dating lds dating planet
It takes the rather simplistic view of "it'll be the same day in the resulting month" - meaning adding months to anything on days 29, 30, 31 is potentially an "error" select add_months(to_date('', 'DD-MM-YYYY'),12) from dual; ADD_MONTHS ---------- the error is because interval expects feb 29th in 2001.. :( November 18, 2005 - pm UTC A month is ambigious.(so atleast with the current versions releases, add_months is more reliable) first of all this interval concept first time i am seeing it. fine if it doesnt work for the below select to_date('', 'DD-MM-YYYY') interval '1' year from dual; then i have two questions: 1) what is the difference between adding interval and add_months? It is not like "a week" Tell me, *what is a month* A year even is ambigous - years do not have the same number of days..SQL select datum,add_months(trunc(datum,'MONTH'),12) 2 case 3 when to_char(datum,'DDMM')='2902' then null 4 else to_number(to_char(datum,'DD')-1) end datum_yar 5 from toto 6* order by 1 DATUM DATUM_YAR --------- --------- 25-FEB-00 25-FEB-01 26-FEB-00 26-FEB-01 27-FEB-00 27-FEB-01 28-FEB-00 28-FEB-01 29-FEB-00 01-MAR-00 01-MAR-01 02-MAR-00 02-MAR-01 03-MAR-00 03-MAR-01 04-MAR-00 04-MAR-01 05-MAR-00 05-MAR-01 06-MAR-00 06-MAR-01 ...DATUM DATUM_YAR --------- --------- 18-FEB-03 18-FEB-04 19-FEB-03 19-FEB-04 20-FEB-03 20-FEB-04 21-FEB-03 21-FEB-04 22-FEB-03 22-FEB-04 23-FEB-03 23-FEB-04 24-FEB-03 24-FEB-04 25-FEB-02 25-FEB-03 26-FEB-02 26-FEB-03 27-FEB-02 27-FEB-03 28-FEB-02 28-FEB-03 01-MAR-02 01-MAR-03 02-MAR-02 02-MAR-03 First, let me clear the confusion most people seem to have about Add_Months Function.
However: a) It doesn't solve the Original Poster's Q, which is to make the Result Day of Month 1 Day less than the Source Date's Day of Month (even when not in end-of-month scenarios).
Kind Regards, Vijay November 17, 2005 - am UTC add_months, as documented and by definition, returns the last_day of the resulting month if you input the last_day of a month to begin with.
add_months( any_last_day_of_a_month, some_number_of_months) returns the last_day of the resulting month.
Also and therefore, it reads more clearly, if you were to translate it to a natural language (i.e if you needed to explain it to someone or someone were trying to understand what it's doing by reading it).
BTW, I say it's a "bug" with the "design" of the Add Months Function, not just the Function because it's doing what its docs claim it was designed to do.
First impressions to get the next year might be to add 365 days...